Major performance issue when trying to load kmz in a lot

Hello everyone,

I'm facing with some major performances issue when I try to load multiple KMZ at once in Cesium.
These performances issue exist in the 3 main browser but goes from lagish to browser crash depending on the browser.
This is caracterised mainly by a hich memory usage in the process where Cesium is hosted.
For example for Firefox it goes from 600 MB to 2.8 GB memory usage after trying to load multiple KMZ.

For test purpose, here is a simple code to try in sandcastle :

https://gist.github.com/theOgrable/0ab4af80958952cdd4ca#file-gistfile1-txt

I use only one KMZ file of 40 KB with an underlying KML doc of 1000 KB for simplification.
If you try to reset with the reset option, you'll notice that memory does not go down significatly. Eventually after some back and forth between upload and reset, your browser will crash.

I first suspected a problem in the unzipped of kmz as this is where browser react very differently (seen in the network analysis from browser's developper tools), but the fact that memory does not go down after reset make me think that there might be another problem.
With garbage collector, maybe ?

The idea underlying this test was to load a huge KMZ file splitted into smaller ones

I'm using last Cesium version, from master git.

Thanks for your suggestions / ideas to resolve this problem.

Olivier

Hi Olivier,

I have same issue and stuck with project.
My file is even bigger then yours. 5MB to 50MB.

can anyone help me how to make file smaller and improve performance.

Thanks

Hello again Cesium team,

I still have no clues of how to resolve this issue.

Could you give me a hint of your thoughts on it ?

Thanks,

Olivier

KML performance issues are a complex thing. There are some things you can do to help, but a lot of it relies on fundamental elements of the browser and how XML is parsed.

See Matt’s post here https://groups.google.com/d/msg/cesium-dev/Pv7ElUvjkTc/qGHX9c63CwAJ for the best breakdown of KMZ performance.

Using Chrome 64bit can help. Have you tried changing your kml to use embeded kmz icons?

Hi Denver,

Thanks for your answer.

I did not seen the post you mentioned before, that's indeed interesting informations.
However, even if Matthew said there were a lot to do to optimize kml file, he did not explain exactly what except for the fact that we should keep the number of placemarks as low as possible.

I also tried your idea to put icons directly in the kmz, however it did not improve my situation, and eventually, browser crashed like before (you can try it in sandcastle with the same code as before and changing ‘http://theograble.github.io/AIS’ by ‘http://theograble.github.io/AIS_unchained’.)

I tried with chrome 64 bit, but there are no significative improvements. I can still see RAM usage going crazy.
Most importantly here, if I reset my placemarks on Cesium, RAM does not go down, so there must be a problem in memory management at some point.
The memory goes down only if I close the tab containing Cesium.

Do you have any idea where the memory leak comes from ? Could you help me locate where it is ?

Thanks

Olivier

To add a little precision to my previous mail. I realise that I used in my code :

viewer.dataSources.removeAll();

In doc for removeAll :

"destroy | Boolean | false | optional | whether to destroy the data sources in addition to removing them."

So by default data is not destroy.
So I replace this line by :

viewer.dataSources.removeAll(true);

It reacts better and in chrome it's fine.
However, memory usage is strange :
- In chrome, I start with 200 MB RAM
- after loading it's around 1.4-1.5 GB
- then I removeAll(true), but I go down only to 1.3 GB
If I do this loop multiple time it stabilizes around 1.4 GB-1.7 GB.
I would expect it to drop to the initial RAM usage of 200 MB after using removeAll(true). Am I wrong ?

Is that a garbage collector related problem ? If so is there a way to force the garbage collector to do its job ?

Now, I can be satisfied with that as it is not crashing so much anymore.
However, I'd like to improve things.

I'm not time constraint in this project, so if the loading is taking up to 3-5 min, it's ok, but...
... I really want Cesium not to freeze on me during loading/parsing. Is this parsing/loading done in the UI thread ?
I don't think so, but I ask it anyway.
In that regards, what can be done so that my application don't freeze during loading ? What should I look for ?

Thanks

Olivier