Jump to content

Event listeners causing Memory Leaks


Vitali
 Share

Recommended Posts

https://github.com/photonstorm/phaser/pull/4024#event-1841241172

https://github.com/photonstorm/phaser/issues/4051

I tried Phaser 3.13 to resolve the issue with 'shutdown' listeners memory leaks, but it's like a magic - the objects appear in 'shutdown' array even in the 3.13 version!

Another similar problem is 'remove' listeners stays in AnimationManager after destroying the Sprite or restarting the whole scene, it also causes memory leaks.

What am I doing wrong?

Link to comment
Share on other sites

https://github.com/photonstorm/phaser/commit/0a166f944f23f4ad05100106d2323eb152f2bbde

They absolutely don't add themselves to the shutdown event any longer. This is a Scene in 3.13 with 91 Images on the display list:

image.png

and here is the same Scene in 3.12:

image.png

The shutdown event has 91 less entries in it in 3.13, exactly as it should do.

Link to comment
Share on other sites

Thanks for the answer!

You're right about the 'shutdown' listener. I've checked this, but my work project says the opposite. And I've found the source of bug. Could you try to create a Container with a Sprite inside, and then invoke destroy() on the Container or Sprite? This is the magic which I talked about, Sprite (and I think all other GameObject's inside the Container) appears inside the shutdown array!

And I can't understand the Animation behaviour. The Animations have destroy() method with "this.animationManager.off('remove', this.destroy, this, true)", but when I'm trying to debug this code while I'm destroying the Sprite, this method never invokes. 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...