Repeated <py-env> additions cause steady WebAssembly memory growth in PyScript
29K reputation · 07 Dec 2023, 06:16 UTC
When developing long‑running PyScript pages that dynamically insert and remove <py-env> blocks to load different packages, developers notice a gradual increase in the reported WebAssembly memory usage that does not drop after each removal.
The goal is to ascertain whether this growth is an intended side‑effect of Pyodide’s module caching or a sign that the interpreter state should be explicitly released. Current documentation does not specify a method to reset the interpreter or free the associated WASM memory, and the effect may differ between PyScript releases.
Is there a supported way to release or reset the Pyodide interpreter state without reloading the page? Does PyScript provide an API to reclaim WebAssembly memory allocated for loaded packages? Should this memory growth be treated as a leak requiring mitigation, or is it acceptable given that memory is reclaimed on page unload?
1 answer
0 question comments
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.