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

Do we need to cancel our query if the world they're attached to is destroyed? #316

Open
LukeWood opened this issue Sep 17, 2024 · 0 comments

Comments

@LukeWood
Copy link

Hey - I'm working on https://bulletz.io which uses miniplex to do all of it's ECS style logic. First of all, great job! Thanks for all of the work on this - I really enjoy using it.

Secondly, I'm struggling a lot with memory leaks. Unfortunately, I think that a ton of values are being captured inside of closures that are then not cleaned up. In particular, I think the queries are what is causing these things to be captured.

When I create a query, I do something like:

this.world.with('isPlayer').onEntityAdded(v => {
     const enemy = game.players.get(v.enemy) // or whatever else
})

I suspect that this is storing a reference to game, which is a temporal object (as well as world), and that these subscriptions are therefore not cleaned up.

Do I need to manually clean up all subscriptions to a world when I want to destroy it? Or is there something else I can do? This feels pretty cumbersome! Do I call disconnect() to destroy a query? I can't tell if this is mean't to be a user facing method or not based on some other implementation details.

Thanks for all the hard work and any guidance!

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

1 participant