Git Product home page Git Product logo

Comments (14)

andrewstart avatar andrewstart commented on May 20, 2024

So it does. That was pretty dumb on my part.

from particle-emitter.

ben-zabloski avatar ben-zabloski commented on May 20, 2024

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.

from particle-emitter.

andrewstart avatar andrewstart commented on May 20, 2024

When I get a chance to take care of this, I'll look around for other references.

from particle-emitter.

andrewstart avatar andrewstart commented on May 20, 2024

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.

from particle-emitter.

ben-zabloski avatar ben-zabloski commented on May 20, 2024

Awesome - I'll check it out tomorrow - Thanks Andrew!

from particle-emitter.

adoxographer avatar adoxographer commented on May 20, 2024

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

particleleak

I'm going to keep trying to figure it out but any help would be appreciated.

from particle-emitter.

andrewstart avatar andrewstart commented on May 20, 2024

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 sprites array when you want to wipe it, I believe with myWebGLRenderer.plugins.sprite.sprites.length = 0;.

from particle-emitter.

adoxographer avatar adoxographer commented on May 20, 2024

@andrewstart unfortunately that doesn't seem to fix it, any ideas?

from particle-emitter.

andrewstart avatar andrewstart commented on May 20, 2024

That was my only easy idea. I'll have to dig into it this weekend.

from particle-emitter.

andrewstart avatar andrewstart commented on May 20, 2024

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 sprites array, but once you do that the particles should get properly taken care of.

from particle-emitter.

adoxographer avatar adoxographer commented on May 20, 2024

@andrewstart that worked, I can confirm they're being properly disposed now.

Thanks!

from particle-emitter.

bigbadwofl avatar bigbadwofl commented on May 20, 2024

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:

emitter.emit = false;

and then a bit later

emitter.destroy();
this.renderer.plugins.sprite.sprites.length = 0;

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.

from particle-emitter.

andrewstart avatar andrewstart commented on May 20, 2024

That should be correct. cleanup() removes any active particles, which shouldn't find any particles if you've waited for all the particles to expire. destroy() is what wipes the particle pool. Are you using a Container or ParticleContainer?

from particle-emitter.

bigbadwofl avatar bigbadwofl commented on May 20, 2024

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.

from particle-emitter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.