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

Possible memory leak in physics collisions? #15

Open
amaccann opened this issue Aug 27, 2019 · 4 comments
Open

Possible memory leak in physics collisions? #15

amaccann opened this issue Aug 27, 2019 · 4 comments

Comments

@amaccann
Copy link

Hey, using your plugin and wired together the basic 'on mouse pressed' example that fires some random bullets. IE:

if (this.input.activePointer.isDown) {
  this.weapon.fire();
}

so that works fine. However, if I include the overlap() Arcade Physics logic to track collisions between my other scene sprites & weapon bullets, I notice that the FPS collapses after a while. It goes from a smooth 60fps, to < 10fps. I keep the mouse button down and after about 10 seconds, the FPS starts dropping. Letting go of the mouse, but the FPS continues to drop.

this.physics.add.overlap(this.allSprites, this.weapon.bullets, (actor, bullet) => {
    bullet.kill();
});

So I don't have any particular debug info: the FPS drop for sure happens if the overlap() logic is included (this.allSprites contains a bunch of normal ArcadeSprite sprites).

Without that overlap logic, holding the mouse button down doesn't cause the FPS drop at all. I wonder is there something going on with the Bullets when they 'die' yet they're still being cached by the ArcadePhysics overlap() function?

The plugin is great and just what I need, but this FPS lag means I can't use it ATM. I probably could hot-patch some 'fake' physics overlap logic, but would be a shame not to use the code provided out-of-box.

@amaccann
Copy link
Author

Also to clarify, this leak happens regardless if the callback with bullet.kill(); is called or not - and whether the callback is defined or not. So this.physics.add.overlap(this.allSprites, this.weapon.bullets); still causes the FPS drop.

@16patsle
Copy link
Owner

Thanks for the in-depth report. I’ll see if I manage to reproduce, and let you know what I find out.

@16patsle
Copy link
Owner

Although it's been a while I though I should let you know that I haven't been able to reproduce the issue. If you still experience it yourself I created an example in examples/physics-overlap.js if you want to try that. Otherwise I guess we can just close the issue.

@amaccann
Copy link
Author

amaccann commented Apr 15, 2020

@16patsle Fair enough; it has been a while lol but I might take another shot at this and see what might have been happening 👍 If you want to close the issue that's fine - thanks for getting back on this though!

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

No branches or pull requests

2 participants