Destroying viewer with 3d tiles doesn't release memory

Hi all,

I am working on a project with 3d tiles. My problem is that once 3d tiles are loaded, viewer.destroy() doesn’t release memory. It looks like the memory never freed. I don’t think it is a matter of 3d tile data since I see the same issue with different 3d tile sets.

To replicate the issue, press a “go” button on the Sandcastle. Whenever the button is clicked, a new 3d tile is loaded. Memory usage keeps increasing and never released. Is there any way to release the memory?

first_load.JPG last_load.JPG

I appreciate your help in advance.

Sandcastle example:

You might consider caching the viewer, and removing the tileset (perhaps you can hide the canvas element when you need it to be removed). There are some known issues with trying to recreate the viewer and the browser not letting resources go:

This modified Sandcastle seems to correctly garbage collect when removing the tileset.

Thank you for your help, Omar.

Your workaround works in the Sandcastle. But, in my project, the cesium canvas is embedded in a Bootstrap modal which is called using ajax. It is supposed to create a new viewer for a new cesium canvas whenever a new modal is shown.

Our team has spent a lot of time and effort to prepare 3d tiles and utilize them within our product. Now, we get stuck because of the memory leak issue. I would really appreciate if you run into any solutions and share with me.

Perhaps you could write a wrapper around the Cesium viewer, so its “destroy” function just hides it and removes all primitives, instead of completely removing the viewer? And then you can pass this custom object to your Bootstrap modal instead of passing the Cesium viewer directly.

Let me know if that helps. What kind of project is this for?