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

Memory leak (particles list is not pruned) #4

Closed
tkers opened this issue Mar 21, 2023 · 2 comments
Closed

Memory leak (particles list is not pruned) #4

tkers opened this issue Mar 21, 2023 · 2 comments

Comments

@tkers
Copy link
Contributor

tkers commented Mar 21, 2023

Hi! First of all, thanks for creating and sharing this library. I've started using this a while ago and it's been perfect for adding subtle effects to my games :)

However, after adding a lot of particles to my game (for example during playdate.update for a continuous effect like smoke), I realised the particles are not cleaned up properly and the performance starts dropping steadily.

I narrowed it down to the main particles table which adds, but never removes, each particle instance:

particles[#particles+1] = self

I'll try out some approaches to fix this and hopefully submit a PR later for this, but wanted to raise this issue in case you have any ideas regarding it already.

@PossiblyAxolotl
Copy link
Owner

PossiblyAxolotl commented Mar 22, 2023

Ooh thanks for catching that, I added the Particle:remove() function which seems to do the job but if you have another idea please let me know

IMG_9189.mp4

(I've had it running for the last 10-15 mins with no frame drops)

@PossiblyAxolotl
Copy link
Owner

also added Particles:removeAll() to prune the list

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