Jump to content

Particles are putting pressure on garbage collector. Why?


puzzler
 Share

Recommended Posts

I'm noticing from the profiler that when I run the particle emitter in my game, the heap builds up over the course of a couple seconds and then drops back down after the garbage collection.  To be sure the test is accurate, I've turned off everything else in my game so it is *only* the particle emitter that is running.  My understanding is that once the initial pool of particles are created (in my case, 200), no more objects should be dynamically allocated, so why is this happening?

My emitter uses a custom particle class that calls the kill() method on the particle when the particle gets more than a certain distance away from the source.

My impression is that by calling kill rather than destroy, Phaser should be able to use the same particles over and over again.  Why is Phaser, apparently, not reusing the particles?

I'm using Phaser 2.6.2.

Link to comment
Share on other sites

By printing a debug statement inside the particle constructor, I can see that the particle system is NOT creating any more than the given 200 particles.  So what is causing Phaser to allocate memory each time a particle is recycled?  Is there some inner arcade/physics object that is dynamically allocated with each recycle?  Is this an issue that is addressed in the later community editions?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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