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

Possible memory leak in decode function? #2

Open
dnish opened this issue Oct 25, 2022 · 2 comments
Open

Possible memory leak in decode function? #2

dnish opened this issue Oct 25, 2022 · 2 comments

Comments

@dnish
Copy link

dnish commented Oct 25, 2022

Hey,
we are using a library which depends on version 0.1.5. We noticed a heavy memory increase in our application and started debugging it via node profiler. After getting some snapshots, we noticed a big JSArrayBufferData object which contains a call to the decode function of the @cwasm/webp package. The object never gets collected by garbage collector, even when we force a cleaning via global.gc().

@LinusU
Copy link
Owner

LinusU commented Oct 25, 2022

Hey!

I think that this is because there is no way to shrink the WASM instance allocated memory once it requests more. I'm sure that there was another thread about this one another cwasm package but I cannot seem to find it now 🤔

It this is the same issue, you should see a constant memory usage around the encoded + decoded size of the largest image ever decoded. But it shouldn't grow unbounded. Is this what you are experiencing?

I'm very open to solutions to this, but I'm not sure that there is something straight forward. Potentially we could schedule a job to with something like setTimeout to tear down and create a new WASM instance if there hasn't been any decode calls in a while 🤔

@LinusU
Copy link
Owner

LinusU commented Feb 27, 2023

Seems like there is some upstream work that could enable us to shrink the memory after each encoding 🙌

WebAssembly/memory-control#6

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