My Three.js application sometimes requires a complete re-render without reloading the page.
I've tried reusing the WebGLRenderer variable to avoid memory leaks, but they still occur. To maintain performance and prevent the multiplication of WebGL contexts causing memory leaks, I need to kill the WebGL context and create a new one every time the scene needs to be redrawn.
Although older versions of Three.js had methods like renderer.deallocateObject
or scene.removeObject
for managing memory, they are no longer supported in newer versions (mine is r69).
My question is: how can I release the WebGL renderer (WebGL context) and start a new one? It's crucial for me to have only one WebGL context throughout the lifetime of my app.
I would appreciate any help, even pure JavaScript solutions without relying on Three.js.
Many thanks