i have created more than 100 primitives. It consumes a certain amount of memory. But when i delete the primitives the memory is not cleared from RAM. can someone please suggest an idea?
Well, a bit hard to give specifics, as the JS garbage collector is hidden, but the general rule is data by reference, so make sure there’s no references to the entities (in objects, arrays or variables). And it can take some time, for example the browser may choose to only run the garbage collection on parts of the JS space at different times, sometime even not at all until a refresh. It’s a bit of a black box.
Next up, do the same exercise for the Cesium JS engine, there’s always a chance there’s some bug in there somewhere that stops the garbage collector from removing it. But I’d start with deleting it, all references, and then time it to see if it gets collected after some time. Wait a few minutes.
I should mention that there are legit reasons for why data sometimes gets stuck (and hard to actually create a fix for), especially caching controllers, change-control engines, and entities that references other entities (either sub-entities, or maybe a stray property reference, or…). Best place to test it out would be to create as small a use case as you can, and see where the bottlenecks might be.
And that’s just the Cesium side, WebGL has it’s own stack and garbage collection for data. I don’t have too much experience from that part of the stack, so I can’t help much there, but the same applies; lose all references so the garbage collector can safely free up the space.
thanks for the help, appreciate it