1. A concise explanation of the problem you're experiencing.
If I add a KML Datasource to Cesium and then remove it, all of the memory used is not released by the browser unless I also remove all entities in the entity collection, destroy the entity cluster and clear the frustum commands. The first two are easy to do, should they be required though? The last item is not something I feel comfortable doing as its getting into Cesium internals and does not feel like it should be necessary.
The DrawCommands in the Scene FrustumCommandsList hold a reference to the BillboardCollection, so all of the billboards remain in memory unless these are cleared out. Is this a memory leak? Or is there a better way to clear out the DrawCommands when removing a Datasource?
2. A minimal code example. If you've found a bug, this helps us reproduce and repair it.
Add the Global Facilities KML and then use one of the remove functions to see how each differs in the remaining memory. The following is the memory usage I see using Chrome Task Manager (looking at the live JavaScript memory). Using the memory dev tool I manually run a GC before recording the memory usage.
Baseline Sandcastle: 50K
After Adding Facilities KML: 170K
Just remove the data source: 138K
Also clear entities: 93K
Also destroy entity cluster: 91K
Also Clear Frustum Commands: 53K
3. Context. Why do you need to do this? We might know a better way to accomplish your goal.
Cesium memory usage continues to grow as users add and remove KML data. This might not be specific to KML, that was just the data source type I used for testing.
4. The Cesium version you're using, your operating system and browser.
Cesium 1.42, Windows 10, Chrome v64