Skip to content

Memory leak in instance creation #42

@koponen-styra

Description

@koponen-styra

Running the following to see the memory leak in action:


import (
        "github.com/bytecodealliance/wasmtime-go"
        "runtime"
)

func main() {
        wasm, err := wasmtime.Wat2Wasm(`
      (module
        (import "" "hello" (func $hello))
        (func (export "run")
          (call $hello))
      )
    `)
        check(err)

        for {
                store := wasmtime.NewStore(wasmtime.NewEngine())
                module, err := wasmtime.NewModule(store.Engine, wasm)
                check(err)

                item := wasmtime.WrapFunc(store, func() {})
                instance, err := wasmtime.NewInstance(store, module, []*wasmtime.Extern{item.AsExtern()})
                check(err)

                // The rest is not required for the leak.

                run := instance.GetExport("run").Func()
                _, err = run.Call()
                check(err)

                runtime.GC()
        }
}

func check(e error) {
        if e != nil {
                panic(e)
        }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions