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 ! release world in nodejs #80

Open
shadow0162 opened this issue Feb 25, 2016 · 2 comments
Open

Memory Leak ! release world in nodejs #80

shadow0162 opened this issue Feb 25, 2016 · 2 comments

Comments

@shadow0162
Copy link

I made an online game by using box2d.js on server side.
one vs battle is a new box2d world. While battle end, I release b2d world by destory.

b2d.destroy(this.world);

But the memory still increase by 40M(almost 150+ b2body).
what the best way to release the memory of box2d world and all bodies?

@kripken
Copy link
Owner

kripken commented Feb 25, 2016

The guaranteed way is to put box2d.js itself and your code inside a function. Then when that function exits, only things you keep holding on to are reachable by the JS engine, and it will eventually GC all the rest.

@shadow0162
Copy link
Author

thanks, I will try it

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