-
Notifications
You must be signed in to change notification settings - Fork 140
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 in prismarine-web-client #333
Comments
To reproduce more quickly, rebind sprint key to Q, and use bot.physics.sprintSpeed=0.9 in the console to move through the world more quickly (I initially produced the error the slow way). |
I've added a repo to make it easier to reproduce the error: https://github.com/kf106/pwc-memleak.git |
open for PR |
I don't understand what you mean. |
The problem is in prismarine-viewer, with worldrenderer.js, primitives.js and entities.js not cleaning up Threejs objects properly. By adding a more thorough dispose function, calling that to remove threejs objects instead of .dispose, and removing references to the objects that go out of view, the system heap size stops growing. dispose.js:
|
Doesn't seem right to need a function like that. Are you sure this is intended usage of threejs? Perhaps it's a bug in threejs not one in prismarine-viewer? Dispose on material/geometry/texture should be all that's necessary. https://threejs.org/docs/#manual/en/introduction/How-to-dispose-of-objects |
It might be a bug in Three. I tried removing just geometry and material in all places I could find, but that didn't work. The removal function did work - it also removes references. I don't have time at the moment to replace it with a simpler removal function. |
OS: Ubuntu 22.04 (probably others - will investigates later)
Browser: Chrome 108.0.5359.124
Node: v16.19.0 (npm v8.19.3)
To reproduce:
Install flying-squid and run
node examples/basic.js
to set up a server, and prismarine-web-client from the repo as of today (commit d82a70a ).Connect pwc to fs and move forward constantly, taking memory heap snapshots in Chrome every five minutes.
The heap never gets smaller, only bigger. If you run fs with a higher base level for the land the effect is more pronounced (set it to 150, say, and you can build up 2Gb of heap pretty quickly). If you run it for a long time (I used
xdotool sleep 3 keydown w+space
) after a while some chunks fail to render and then the window crashes with an out of memory error. (Aw snap!)The text was updated successfully, but these errors were encountered: