Free memory of HashMap

I’m using HashMap to hold assets, and it appears that removing entries doesn’t free up memory even after some time. I attempted to use shrink_to_fit to adjust the capacity, and while it did adapt, it seems the memory isn’t released until it’s reused.

Am I overlooking something, or is there a way to instruct the canister to release unused memory?

Is there a way to instruct the canister to release unused memory?

There is no way currently unfortunately. WebAssembly memories do not support shrinking.

2 Likes

A pity. Thanks for the feedback.

Do you know if this some WebAssembly standard feature that is being discussed (I mean generally speaking) or not really?

This thread looks like the open discussion about standards for shrinking / discarding memory in WASM: https://github.com/WebAssembly/design/issues/1397