Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Naive usage of wastime rust crate leaks memory #2627

Closed
hjfreyer opened this issue Feb 1, 2021 · 3 comments
Closed

Naive usage of wastime rust crate leaks memory #2627

hjfreyer opened this issue Feb 1, 2021 · 3 comments

Comments

@hjfreyer
Copy link

hjfreyer commented Feb 1, 2021

This may well just be me holding the crate wrong, but my application keeps using more and more memory every time I create and execute an instance.

I have a wasm32-wasi Rust binary that I want to run in a wasmtime sandbox. The binary's main() reads some data from stdin, writes it to stdout, and exits. I want each execution of the binary to be in its own independent sandbox, and I want to minimize latency. As such, I keep an Engine and a Module around between executions but drop the Instance, Store, etc. Or at least, I drop the Rust values, but it seems that the memory doesn't actually get freed.

Here's my code: https://github.com/hjfreyer/pictophone-be/blob/09bbe890c5fa8387d3e590209d7231ce48b130e4/server/src/runner.rs#L34

Is this a bug? Am I doing it wrong? I'm using version 0.22.0 of the wasmtime, wasmtime-wasi, and wasi-common crates.

@alexcrichton
Copy link
Member

Thanks for the report! What you're doing looks correct, but I believe that this is a bug in Wasmtime. I believe #2017 addresses the problem, so I'll take another look at landing that.

@hjfreyer
Copy link
Author

hjfreyer commented Feb 2, 2021

Confirmed that that fixed it! Yay! Thank you!

How can I track when the change lands and I can get off of main?

@alexcrichton
Copy link
Member

Ok thanks for confirming! I'd recommend following the releases of this repository, so you'll get a notification when we publish the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants