Code Monkey home page Code Monkey logo

Comments (4)

mathetake avatar mathetake commented on June 15, 2024

@fzy-Line Could you please provide me the followings for detail ?

  • The version or commit hash of this SDK
  • The extension's code
  • The configuration yaml of Envoy
  • The version of Envoy (Envoy or Istio/proxyv2) and it's commit hash

FWIW, #86 resolved some memory leak issue.

from proxy-wasm-go-sdk.

mathetake avatar mathetake commented on June 15, 2024

BTW, there's no way to grow VM's maximum memory from user program side. The "grow" instruction (https://webassembly.github.io/spec/core/syntax/instructions.html#syntax-instr-memory) should be inserted in in the compiled binary by your compilers and developers shouldn't care about that.

from proxy-wasm-go-sdk.

Echo-Van avatar Echo-Van commented on June 15, 2024

I found the cause of the OOM. It doesn't looks like an proxy-wasm extension problem, but a problem of my code implementation. In golang, the map will not release memory after deleting elements. In my extension's code, I use a global map to share context:

var records map[uint32]*RequestInfo

func saveRequestInfo(key uint32, requestInfo *RequestInfo){
	mutex.Lock()
	defer mutex.Unlock()
	records[key] = requestInfo
}

func (ctx *httpHeaders) OnHttpRequestHeaders(numHeaders int, endOfStream bool) types.Action {

	requestInfo := new(RequestInfo)

	// Get info from http head and set to requestInfo
	// ......

	// put requestInfo to map
	saveRequestInfo(ctx.contextID, requestInfo)

	return types.ActionContinue
}


func (ctx *httpHeaders) OnHttpResponseHeaders(numHeaders int, endOfStream bool) types.Action {

	requestInfo := records[ctx.contextID]

	// use these info and send a httpcall
	// ......

	// delete map element
	delete(records, ctx.contextID)

	return types.ActionContinue
}

The reference: golang/go#20135

So I want to know if there is a better way to share context in Proxy-wasm extension.

from proxy-wasm-go-sdk.

mathetake avatar mathetake commented on June 15, 2024

why not just embed the info to fields in your httpHeaders struct? btw you do not need to have mutex anyway since Proxy-Wasm env is single-threaded.

from proxy-wasm-go-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.