-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
wasmtime:apiRelated to the API of the `wasmtime` crate itselfRelated to the API of the `wasmtime` crate itself
Description
This program:
use wasmtime::*;
fn main() -> Result<()> {
let engine = Engine::default();
let mut store = Store::new(&engine, ());
let module = Module::new(
&engine,
r#"
(module
(import "" "" (func (param funcref)))
(elem declare func $x)
(func $x)
(func (export "")
ref.func $x
call 0)
)
"#,
)?;
let func = Func::wrap(&mut store, |_: Option<Func>| {});
let i = Instance::new(&mut store, &module, &[func.into()]).unwrap();
let f = i.get_typed_func::<(), ()>(&mut store, "")?;
loop {
f.call(&mut store, ())?;
}
}
will infinitely consume memory until killed. Basically what happens here is that each time a host function with a funcref
parameter is invoked Wasmtime creates a new Func
which pushes onto an internal store-local vector that is never shrunk. That means that the memory usage of a store is O(calls) which is generally not a desirable property we want to have.
This is not a regression but is something that's been around for quite a long time. I'm working on fixes in this area though and wanted to file an issue about this.
Metadata
Metadata
Assignees
Labels
wasmtime:apiRelated to the API of the `wasmtime` crate itselfRelated to the API of the `wasmtime` crate itself