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

Bug: Memory Leak / Inappropriate cleanUp - stage.renderGroup cleanUp is not there #10533

Closed
konstantincheban opened this issue May 13, 2024 · 3 comments · Fixed by #10566
Closed
Assignees

Comments

@konstantincheban
Copy link

Current Behavior

When analysing the memory report I noticed that after closing the view with PIXI app I still see PIXI instances in the memory. Digging deeper into the chain, I noticed a common instance for leaked elements is renderGroup. Then I noticed renderGroup is cleared for elements in the Container.removeChild method:

child.renderGroup = null;

However for the stage element this method is not called as it has no parent:
public destroy(rendererDestroyOptions: RendererDestroyOptions = false, options: DestroyOptions = false): void


Screenshot 2024-05-13 at 6 38 21 PM

On our end, we call the destroy method for app:
_pixi.destroy(true, {children: true, texture: true, baseTexture: true })
*_pixi - PIXI Application instance

Expected Behavior

renderGroup should be cleared for stage to remove references to other elements and let GC do its job.

Steps to Reproduce

Thing I would like to point out is that we are using a slightly unusual approach, we store PIXI on window, perhaps this is the reason why it keeps refs in memory, however it would be cool to clear the renderGroup for stage, this would be valid from my point of view.

Environment

  • pixi.js version: 8.1.1
  • Browser & Version: 124.0.6367.158 (Official Build) (x86_64)
  • OS & Version: MacOS
  • Running Example:

Possible Solution

To overcome this issue I remove references to elements manually this way:
_this.pixi.stage.renderGroup.childrenRenderablesToUpdate = {};
_this.pixi.stage.renderGroup.childrenToUpdate = {};
_this.pixi.stage.renderGroup.instructionSet = null;

However it would be great to do it directly in the destroy method of the Application.

Additional Information

Let me know if I missed something or there is already a solution for this issue. Thanks!

@GoodBoyDigital
Copy link
Member

interesting! thank you for sharing @konstantincheban and thank you for such a well constructed PR description! Let me take a look!

@GoodBoyDigital
Copy link
Member

heya! should be sorted in the next release! If you could verify on this branch that would be ace. Thanks!!

@konstantincheban
Copy link
Author

@GoodBoyDigital it works fine now, I don't see this leakage with your fix, clean up works fine. Thank you for resolving this issue!

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

Successfully merging a pull request may close this issue.

2 participants