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

Add dispose functions to release all resources #73

Open
hansagames opened this issue Jun 2, 2020 · 3 comments
Open

Add dispose functions to release all resources #73

hansagames opened this issue Jun 2, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@hansagames
Copy link

Any plans to add dispose for textures , materials, meshes to release resources ?

@gordonnl
Copy link
Contributor

gordonnl commented Jun 2, 2020

Hey, yeah I definitely would like to look into this further. Currently I don't have a solid grasp over what needs to be released. Do you know of any good resources?
Cheers

@hansagames
Copy link
Author

Yes as I created dispose now a bit around framework: :)
1)Textures need to be removed gl.deleteTexture(texture.texture);
2) Texture need to be unbindede:
renderer.gl.bindTexture(renderer.gl.TEXTURE_2D, null);
renderer.gl.bindTexture(renderer.gl.TEXTURE_CUBE_MAP, null);
this is for webgl 1, fro 2 there can be more texture types
3) Geometry and buffer as I saw are already implemented
4) Program remove I saw as well

Also would assume all referenced gl / renderers should be removed as they can get cycle reference, same goes for internal states

To make it working out of box renderers should have references to all textures / programs and meshes if not dispose could be implemented per object only and then user would be responsible to call them.

Some resources:
https://stackoverflow.com/questions/23598471/how-do-i-clean-up-and-unload-a-webgl-canvas-context-from-gpu-after-use
very few things related to process: https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/WebGL_best_practices

@eXponenta
Copy link
Contributor

Technically it is not necessary.
Context will a flushed after losting, for ex - delete canvas or reload a page.
But if you use context a temporary, for ex, animation on SPA, or visualising library - this is maybe a usifull to prevent memory leaks.

@gordonnl gordonnl added the enhancement New feature or request label Mar 12, 2021
@gordonnl gordonnl changed the title Would be nice to have dispose function to release resources Add dispose functions to release all resources Mar 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants