Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when we use viewer.destroy after viewer.flyTo(some entity or dataSource),will cause memory leaks #8378

Open
itfsw opened this issue Nov 8, 2019 · 2 comments

Comments

@itfsw
Copy link

itfsw commented Nov 8, 2019

Sandcastle example: Example
Browser: Chrome

  1. when use zoomTo will never case;
  2. use flyTo will like this:
    QQ截图20191108182611
  3. we guess something happened at scene.postRender -> updateZoomTarget -> viewer._zoomIsFlight -> camera.flyToBoundingSphere -> cancel when viewer.destroy
    so we try
viewer.flyTo(xxx).when(()=>{
    viewer._zoomIsFlight  = false
})

before use destroy, it still cannot free entity object,so it may happend when use flyTo method

@OmarShehata
Copy link
Contributor

Thanks for the Sandcastle @itfsw . I can see by capturing a heap snapshot, with the zoomTo and without the zoomTo, after they complete, that in one case if you filter for "Entity" you'll see the memory still exists, and the other it does not.

I think this is worth looking more into.

@lLeiyi
Copy link

lLeiyi commented May 16, 2024

Cesium.TweenCollection.prototype.update = function (time) {
  const tweens = this._tweens;

  let i = 0;
  time = defined(time)
    ? time / TimeConstants.SECONDS_PER_MILLISECOND
    : getTimestamp();
  while (i < tweens.length) {
    const tween = tweens[i];
    const tweenjs = tween.tweenjs;

    if (tween.needsStart) {
      tween.needsStart = false;
      tweenjs.start(time);
    } else if (tweenjs.update(time)) {
      i++;
    } else {
      tweenjs.stop();
      tweenjs._group.remove(tweenjs); //important
      tweens.splice(i, 1);
    }
  }
};

I find in TweenCollection.update tweenjs.stop(); can not clear _group, then _group will continue to grow and there is no way to release. _group retains the reference chain of the entity. So I manually cleared _group.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants