Experiencing memory issues

Hi!

Currently I'm using Cesium to visualize certain activity of our userbase around the globe, which will be displayed on a Asus chromebox with an i3 processor.

However, after running for a certain period of time, Chrome runs out of memory and my application crashes. It does run very smoothly for a while however. I believe this indicated there is a memory leak of some sort?

What I'm currently doing:

Using WebSockets I stream from a worker, I receive activities and create entities at their locations, I also save activities in memory, this can increase to up to 2000 / 5000 entities.
After a certain period of time, I remove all the entities and the activities from memory and start over.

It's after resetting twice that the Chromebox runs out of memory. Using the chrome devtools, I found that the n.onmessage call in Cesium uses the most memory.
I'm not sure where to start to tackle this problem.

Some code examples:
How I add entities:

     const entity = new Cesium.Entity({
            id: activity.id,
            position: surfacePosition,
            point: {
                show: true,
                color: Cesium.Color.SEASHELL,
                pixelSize: entityProperties.pixelSize,
                outlineColor: activityTypeColors[activity.type],
                outlineWidth: pixelSize / 2,
                scaleByDistance: new Cesium.NearFarScalar(10, 0.5, 1000, 1)
            }
        } as any);

        this.viewer.entities.add(entity);

How I remove entities:

    this.viewer.entities.removeAll();

If anybody would be knowing more about this, that would be awesome :)! If this is all a bit unclear, I'd be happy to give more information.

Chrome running on Chromebox: 70.0.035
Cesium version: 1.40

I just replaced the Entities with PointPrimitives, I'm seeing a small performance win, but it crashes on the Chrome Box nonetheless..

Your approach and code looks alright to me. It’s definitely concerning that it crashes and if there’s a memory leak there we’d like to find it.

Are you able to consistently reproduce this? Like, instead of just waiting for the server update to remove the entities, can you try manually triggering it a few times and seeing if it happens? If you can provide a way for us to reproduce this issue (a Sandcastle would be great) we can open a GitHub issue.

Also, if you use the unminified version of Cesium the profiler might be able to give you more information.