Manually clearing out Pyscript from Browser Memory

I’m working on a project that uses PyScript in a pop-up window to load a large amount of data and libraries, which causes the browser’s memory usage to increase significantly to around 4 GB. Even after closing the pop-up, the memory usage remains at 4 GB, whereas it was only about 900 MB before loading PyScript.

Is there a way to manually clear PyScript from the browser’s memory once the pop-up is closed?

Thanks!

  1. I attempted to manually clear PyScript from the memory by removing script elements from the DOM and using JavaScript functions to clear variables and perform garbage collection.

  2. I also tried using various methods to unload or destroy the PyScript environment and any associated Pyodide instances, but none of these approaches seem to free up the memory.

  3. Additionally, I searched for documentation or methods that would allow me to manually close the PyScript session or unload it from memory but didn’t find a direct solution.