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

Storage leaks #196

Closed
antithug opened this issue Jun 15, 2021 · 2 comments · Fixed by #226
Closed

Storage leaks #196

antithug opened this issue Jun 15, 2021 · 2 comments · Fixed by #226

Comments

@antithug
Copy link

I'm using prismarine-web-client, and threejs objects are not getting released. I believe you have to 'dispose' of all the threejs objects (textures, materials, etc.) to get them to release the webgl data. With a big world, you can only play for a short time before the browser tab quits.

When a chunk is unloaded in the web client, it seems to be handled properly - the prismarine chunk is deleted. And that should release the underlying threejs objects, but you need to explicitly dispose of the textures, materials, etc. If you look at the heap snapshots, the storage that leaks is the system/JSArrayBufferData, which I think is the webgl system data. Everything else looks fine.

@Karang
Copy link
Collaborator

Karang commented Jun 15, 2021

Additional infos:

  • Terrain texture and material are shared for all chunks, so their lifetime is the duration of the application, there is no need to release them
  • Entity materials are created for each entity, we can dispose of them as a temporary fix, but the real fix would be to have a cache
  • Entity textures (actually all textures) are managed by a cache so they are loaded once and reuse so that shouldnt be an issue either
  • We should check if the geometry buffers are released (there are no explicit code other than simply removing the mesh from the scene) that could be the leak you are viewing

@antithug
Copy link
Author

Maybe the meshes is enough. Can you point me to the code to make the fix? I can test it quickly.

rom1504 pushed a commit that referenced this issue Nov 7, 2021
* Fixes a memory leak (#196)

* Extra ;

* Found another one in the wild!

* Garbage collection in primitives.js

* Garbage collection in entities.js

* Fixes null references

* Trigger CI
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

Successfully merging a pull request may close this issue.

2 participants