Open itfsw opened 4 years ago
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.
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.
Sandcastle example: Example Browser: Chrome
before use destroy, it still cannot free entity object,so it may happend when use flyTo method