You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this application, if the Module object is cached to a field between calls to run, RSS does not increase after the first run.
Expected behavior
I would expect that
a) Memory can be freed when the local variable goes our of scope, i.e. memory should drop to lower level already after the first run
b) Memory does not increase even more for each (re-)creation of the Module
Additional context
Already the absolute memory consumption (~90MiB) is quite high. I guess that is the memory of the wasm instance. I further guess that this instance is not freed due to some cyclic pointers between the python stack and the extension.
One might argue that this leak is not so problematic, because the (stateless) Module instance should be cached between requests, or de-/serialized as suggested by the documentation. However, this adds some complexity in a real-world web application. My actual project is a flask-based REST-API, where potentially multiple service threads could access such a cashed instance. Also I aim to load .wasm files dynamically, so I would still need a way to free memory.
The text was updated successfully, but these errors were encountered:
Describe the bug
I may hit a memory leak when creating a WebAssembly Instance. RSS does increase with each created
Module
object.Steps to reproduce
I created a MWE repository:
https://github.com/j-blue-arz/wasmer-python-memory-leak
Example run:
In this application, if the
Module
object is cached to a field between calls torun
, RSS does not increase after the firstrun
.Expected behavior
I would expect that
a) Memory can be freed when the local variable goes our of scope, i.e. memory should drop to lower level already after the first
run
b) Memory does not increase even more for each (re-)creation of the Module
Additional context
Already the absolute memory consumption (~90MiB) is quite high. I guess that is the memory of the wasm instance. I further guess that this instance is not freed due to some cyclic pointers between the python stack and the extension.
One might argue that this leak is not so problematic, because the (stateless) Module instance should be cached between requests, or de-/serialized as suggested by the documentation. However, this adds some complexity in a real-world web application. My actual project is a flask-based REST-API, where potentially multiple service threads could access such a cashed instance. Also I aim to load
.wasm
files dynamically, so I would still need a way to free memory.The text was updated successfully, but these errors were encountered: