puzzler Posted July 1, 2017 Share Posted July 1, 2017 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 More sharing options...
puzzler Posted July 1, 2017 Author Share Posted July 1, 2017 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 More sharing options...
samme Posted July 1, 2017 Share Posted July 1, 2017 Normal particle recycling is mostly flipping particle.exists on and off and resetting physics properties. You should try to find where your allocations are happening: https://developers.google.com/web/tools/chrome-devtools/memory-problems/#spot_frequent_garbage_collections. Link to comment Share on other sites More sharing options...
Recommended Posts