-
Notifications
You must be signed in to change notification settings - Fork 124
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
Particles are not being garbage collected after Emitter.destroy() #22
Comments
So it does. That was pretty dumb on my part. |
No worries - programming happens! I noticed when I was debugging a box2d particle I created - the box2d bodies weren't being cleaned up. There may also be a few other memory issues too - Even after I modified the for loop to continue, particles seem to be sticking around when I check the heap snapshot profiler in chrome. |
When I get a chance to take care of this, I'll look around for other references. |
I released version 1.6.3, which fixes the emitter issue and does other cleanup improvements. I didn't see any other references within the library that would cause particles to stick around, though. |
Awesome - I'll check it out tomorrow - Thanks Andrew! |
Hi, I've been following this as well and have been trying to properly delete the particles but without success as well. Having updated to 1.6.3 the problem still remains @andrewstart the issue is that it's being referenced by the renderer and never let go, unlike normal sprites I'm going to keep trying to figure it out but any help would be appreciated. |
Ah, I see - the SpriteRenderer is resetting the batch size in order to overwrite sprite batch entries which I assume has performance benefits from not trying to shrink and grow an array all the time. It also has the side effect of keeping references to destroyed sprites, if you have fewer sprites to draw than before. When you destroy a particle emitter, you suddenly have far fewer sprites than before. A workaround would be to reset the SpriteRenderer's |
@andrewstart unfortunately that doesn't seem to fix it, any ideas? |
That was my only easy idea. I'll have to dig into it this weekend. |
The other reference keeping the particles from getting garbage collected has been fixed in 1.6.6. You'll still need to reset the SpriteRenderer's |
@andrewstart that worked, I can confirm they're being properly disposed now. Thanks! |
Upgraded to the latest pixi (4) and pixi particles (1.6.7) and particles are still not being destroyed properly. Am I correct in assuming I can do:
and then a bit later
When I step into the cleanup function, it doesn't find any particles to destroy (I wait until the particleCount == 0) even though I can still see a few faint dots on the screen. |
That should be correct. |
Thanks for getting back to me! I'm using a Container but I found my issue. I was removing the emitter from an array right after destroying it. Moving the array.splice to right before the emitter.destroy resolved my problem. |
Calling particle.destroy nullifies particle.next causing the for loop to exit after destroying the first particle.
The text was updated successfully, but these errors were encountered: