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

Dispose tile textures #61

Merged
merged 1 commit into from
Jul 10, 2023
Merged

Conversation

StrandedKitty
Copy link
Contributor

I've read through the code and haven't found any mention of deleting old tile textures. In Three.js textures need to be deleted explicitly, see Textures section here: https://threejs.org/docs/#manual/en/introduction/How-to-dispose-of-objects

In this PR I've added Texture.dispose() for color textures and heightmap textures (only for MapHeightNodeShader). I'm not sure whether this is the best way to implement this.

@aldipower
Copy link

Ha, what an coincidence.
Having troubles which faster moving maps, where memory is eaten more and more up by geo-three to the point the browser crashes.

I started to look into the geo-three myself and came to something similar with disposing objects and tiles, but unfortunately I was unable to compile geo-three only getting this error at runtime, so I could not proceed.:

THREE.WebGLProgram: Shader Error 0 - VALIDATE_STATUS false

Program Info Log: Must have a compiled vertex shader attached:

Here is a memory snapshot during runtime, all this objects and arrays building more and more up, and never gets released, until the point of crash.
grafik

I think this are not only map textures, but also meshes and other three.js objects, that never gets disposed.

@tentone Would be great, if you find some time to help us with this issue and maybe we can get to new release together with fixes tackling cleanup issues.

@StrandedKitty
Copy link
Contributor Author

@aldipower Just to clarify, are you talking about RAM or VRAM? In this PR I'm addressing a possible VRAM leak (textures from disposed tiles don't get removed from VRAM). But you've shown a heap snapshot, so I don't really understand what's this about. If you have a heap snapshot it shouldn't be hard for you to find the source of your memory leak.

@aldipower
Copy link

@StrandedKitty Yes, my post does not address directly, but maybe partly, your PR I guess.
My post is about geo-three is filling up the RAM, when used in long or fast running scences.
The relation to your PR is 'cleaning up unused objects generally'.

My problem is, if I compile geo-three myself, I cannot run the lib, because I get this THREE.WebGLProgram: Shader Error 0 - VALIDATE_STATUS false error, which I do not get at the pre-compiled lib. So, I cannot test any code changes, I potentially can do. How did you develop on geo-three?

@tentone
Copy link
Owner

tentone commented Jul 10, 2023

Thanks a lot!

Completly missed these. PR merged! Build seems to be failing but should be an easy fix!

@tentone tentone merged commit 5b4c9d3 into tentone:master Jul 10, 2023
0 of 2 checks passed
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 this pull request may close these issues.

3 participants