Out of memory issue

Hi,

When I tried to load and remove 2000 entities using CZML Datasource after some time I am getting out of memory error in chrome and IE11. IE11 exhibits this behavior quicker compared to chrome. I observed that browser memory is not clearing when we remove data source. Could you please check whether it is a bug or not?

Thanks,
Gayatri

Interesting!

We are seeing increasing memory consumption in our C# application with Cesium running in a web browser control (IE11). Quite a prroblem because our application should run for weeks/months without rebooting.

If there is no user interaction, our application loops through a sequence of camera viewpoints, looking at a .gltf model.

With our C# app it was not clear what the cause is, so I created a test C# application with a few empty panels, and with Cesium in the main panel. The app had no other functionality. In 4 days it went from 157MB to 613MB, on day 1 I did some zooming, but there was no other interaction. All tests were done on a windows 8.1 machine.

In a second test I ran Cesium in the IE11 browser (showing Cesium/Apps/HelloWorld.html). In 25 hours it went from 93MB to 198MB, again only some zooming in the first hour or so.

I plan to repeat this test this using the Chrome browser, but it would be interesting to know if there are known memory leaks in Cesium or in IE11.

Are there any tools available in Cesium (or javascript) to monitor memory usage?

Thanks, Willem

All of the major browsers have a wealth of memory debugging and profiling tools built into them. You can take heap snapshots, monitor individual tab memory consumption, etc… If you are building web applications, I strongly recommend becoming intimately familiar with these tools on the browser of your choice (though they are pretty similar from browser to browser). Here’s the doc for Chrome: https://developer.chrome.com/devtools

As far as memory leaks, I don’t know of any in Cesium itself, but it’s certainly possible. They can also be introduced memory at the application level. A lot of the time these are not traditional memory leaks, but instead result from unbounded growth (such as a list that grows forever).

Gayatri, if you have a small example that can reproduce the problem, definitely let us know. I’ve never seen the type of out of memory issue you are seeing with such a small number of objects.

Hi Matthew,

Thanks for your reply. Please find the attached sample application code to reproduce this issue in IE11. I tried to perform add and remove of czml data source (1000 entities) for every 5 seconds then after some time (approximately 5 to 10 min) I am getting “Out of memory error” in IE11. Also I am sharing the jsfiddle link for the above mentioned app and screenshot of the issue. Let me know if anything else needed from my end.

http://jsfiddle.net/ajga48pz/7/

Thanks,

Gayatri.

sample.rar (4.18 MB)

hi Matthew,

I see one bug reported in Microsoft , is it something related?

thanks
srini

Hi Matthew,

Did you verify the sample attached? Could you please let me know whether the memory leak is from Cesium or IE11?

Thanks,

Gayatri.

Hi Matthew, Gayatri, Srini,

I have made a small sandcastle example that demonstrates the issue in IE11 (about 450MB increase in 24 hrs, Cesium version 1.12), Chrome seems to be OK (or at least much better).

The IE11 memory debugger does not work in the Sandcastle environment, so I’ll have to rework the example to use the memory tool. Given the complexity of Cesium it good be difficult to find the cause…

In my example I constantly zoom to the an entity (a pin) from different heights. I was wondering if the IE11 issue that Srini refers to (deleteTexture leak) has anything to do with zooming.

Thanks, Willem

var timerId;

var heightIdx = 0;

var heights = [10000000, 1000000, 10000, 500]; // camera heights

var viewer = new Cesium.Viewer(‘cesiumContainer’,

                           {timeline : false, animation : false,

                           baseLayerPicker: false, fullscreenButton: false,

                           geocoder: false, infobox: false, navigationHelpButton: false, homeButton: false,

                           scene3DOnly: true,

                           sceneModePicker: false, selectionIndicator: false, targetFrameRate: 25});

viewer.scene.globe.tileCacheSize = 10000;

viewer.scene.globe.maximumScreenSpaceError = 1;

viewer.scene.debugShowFramesPerSecond = true;

var pinBuilder = new Cesium.PinBuilder();

var bluePin = viewer.entities.add({

id: 'pin/0',

position : Cesium.Cartesian3.fromDegrees(7.28706166666667, 43.693555),

billboard : {

    image : pinBuilder.fromColor(Cesium.Color.ROYALBLUE, 48).toDataURL(),

    verticalOrigin : Cesium.VerticalOrigin.BOTTOM

}

});

viewer.zoomTo(viewer.entities);

function doAnimation() {

// console.log('heightIdx ' + heightIdx);



// fly to the pin.

doFly('pin/0', 5.0, 0, -45, heights[heightIdx]);



// next camera height

heightIdx = ++heightIdx % heights.length;

}

function doFly(targetId, flyTimeSeconds, headingDegrees, pitchDegrees, distanceMeters) {

var entity = viewer.entities.getById(targetId);

if (entity) {

    var heading = Cesium.Math.toRadians(headingDegrees);

var pitch = Cesium.Math.toRadians(pitchDegrees);

var promise = viewer.flyTo(entity, {

duration: flyTimeSeconds,

offset: new Cesium.HeadingPitchRange(heading, pitch, distanceMeters)

});

    promise.then(function (result) {

        if (result) {

            // ok

        }

        else {

            console.log('promise result false');

        }

    }).otherwise(function (error) {

        console.log('promise error');

    });

}

else {

    console.log('no entity');

}

}

Sandcastle.addToolbarButton(‘Toggle Animation’, function(){

if (timerId) {

    clearInterval(timerId);

    timerId = undefined;

    console.log('Animation stopped');

}

else {

    timerId = setInterval(doAnimation, 10 * 1000);

    console.log('Animation started');

}

});

I have not succeeded in getting information from the IE11 memory tool that points to a source of the problem, so deleteTexture() is the main suspect at the moment.

It looks like there will not be an IE11 fix for this issue (see https://connect.microsoft.com/IE/Feedback/Details/1662127). The new Windows-10 Edge browser is not available as WPF browser-control, it is not clear if that will change in the future.

Is there any chance that Cesium could work around the deleteTexture() issue?

Thanks, Willem

FYI, I received a mail from Microsoft this week saying that the Edge browser is now supported in WPF applications. I have not tested this (and will not have time for it in the near future).

See https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/7749954/ and https://blogs.windows.com/msedgedev/2018/05/09/modern-webview-winforms-wpf-apps/

Thanks, Willem