wasmerio / wasmer-go

🐹🕸️ WebAssembly runtime for Go
https://pkg.go.dev/github.com/wasmerio/wasmer-go
MIT License
2.8k stars 161 forks source link

fix: Force finalizers to explore the graph of objects #277

Closed Hywan closed 3 years ago

Hywan commented 3 years ago

First, this patch provides new Close methods on some “top types” (Store, Module, Instance etc.). The Close methods are redundant to the runtime finalizers, but they are useful to force to destruct a specific type manually before the Go GC collect it.

Note that calling Close will remove the runtime finalizer attached to the object.

Note that runtime finalizers call the Close method if defined on the current object.

Second, this patch forces the destructors (now the Close methods) to destruct the children attached to the current object. Let's see it in details:

Running the script written by @prep in https://github.com/wasmerio/wasmer-go/issues/262 shows that there is no more memory leaks.

Fix #262. Fix #269.

Hywan commented 3 years ago

bors try

Hywan commented 3 years ago

bors try

bors[bot] commented 3 years ago

try

Already running a review