wasmer-go icon indicating copy to clipboard operation
wasmer-go copied to clipboard

Module memory leak

Open levi9311 opened this issue 3 years ago • 2 comments

Thanks for the bug report!

Describe the bug

I think there might be a memory leak when creating a module.

When I create a module in an endless loop, the memory usage as is shown by free command on Linux increases endlessly.

Steps to reproduce

Here is the code.

package main

import (
	"io/ioutil"
	"runtime"
	"time"

	"github.com/wasmerio/wasmer-go/wasmer"
)

func main() {
	wasmBytes, _ := ioutil.ReadFile("./demo.wasm")
	go func() {
		for {
			time.Sleep(time.Second)

			runtime.GC()
		}
	}()
	for {
		engine := wasmer.NewEngine()
		store := wasmer.NewStore(engine)
		module, _ := wasmer.NewModule(store, wasmBytes)
		module.Close()
		store.Close()
	}
}

Expected behavior

I expect the memory usage is under a stable number.

Actual behavior

Memory usage keeps increasing.

levi9311 avatar Jan 06 '22 09:01 levi9311

This is fixed in Wasmer 2.1, but the Go bindings have not yet been updated to use that version.

Amanieu avatar Jan 06 '22 11:01 Amanieu

I'm also hit by this issue. Is there an ETA for updated Go bindings?

Is there something I can do to help?

wouterh avatar Mar 25 '22 11:03 wouterh