Memory Management For Polyline With Many Positions

Hello,

I am new to Cesium and I am trying to display a line which connects many lat/long positions (~22K) and I’m seeing the browser memory spike around 130 MB. My requirements call for as many as 25 of these lines being displayed at a time. Displaying several causes the memory to spike around 400 MB.

It appears to be a rendering problem since I’m seeing the same result whether I build the array of positions as the playback changes or if I only build it once and display them. My current implementation is using a polyline for each line. Here is a sample:
indent preformatted text by 4 spaces
this.polyline = new Cesium.Entity({
name: getName(),
polyline: {
material: new Cesium.ColorMaterialProperty( this.getColorCallback() ),
positions: new Cesium.CallbackProperty( function() {
return myArray;
}, false ),
show: new Cesium.CallbackProperty( function() {
return isVisible();
}, false ),
width: 2
}
});
indent preformatted text by 4 spaces

In the above, “myArray” has already had its lat/longs converted using “Cesium.Cartesian3.fromDegrees()”

The line displays accurately. My question is: Am I pushing the limits of Cesium with so many points or is my approach above a less than ideal way to accomplish my goal?

My hope is it’s the latter.

Thank you

The discussion here may be helpful: Performance differences due to distance. Specifically, if you have lines over a long distance, you can set the arcType to NONE to reduce the amount of computations needed if you don’t need CesiumJS to handle curving the line over the surface of the Earth for you.

1 Like

Do you really need the line to re-compute its positions every frame? I believe that’s what’s happening when you use a CallbackProperty for positions. If you aren’t changing your points very frequently, you might want to see how it performs using a single constant array. (You can always assign to this.polyline.polyline.positions later when the line is supposed to change.)

2 Likes

I apologize for just getting back to you. Life happened. Those are good ideas, @omar and @James_B! I’ll give them a try and let you know. Thanks so much!