custom datasource consumes a lot of time in garbage collection process


First I would like to thank you for cesium. It's great tool and it's one of the best open source projects I saw.

my problem:
I implemented custom datasource which is kind of vector tile datasource.

In every update call, there is a check based on camera properties and new datasource instance is made for every new "tile". Not relevant datasource instances are removed.

This works just fine, but after some minutes of camera movement I see the viewer "stutter" and eventually completely stop.

Profiling indicates that the garbage collection is the reason.
I think to make "object pooling", as described here:

But before I'm starting I want to ask if you have any experience with such situations and if you have any recommendations/best practices/approaches which could solve this problem.
If object pooling is also your recommendation, which objects are most important to recycle?

Thank you very much

Object pooling/re-use is absolutely the solution to your problem. For code that gets called every frame, you should reuse every object if possible. That being said, processing vector tiling in this way is not ideal. You might be interested in checking out our new 3D Tile initiative which will hopefully solve the streaming geospatial data problem in the general case: