-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
Closed
Labels
Description
Describe the bug
Currently, textures from glb files are loaded as ImageBitmap objects, which are not garbage collected by default - one needs to call the close() method
However, the Texture.prototype.dispose() method doesn't do it.
To Reproduce
- Open https://gltf-viewer.donmccurdy.com/ in Chrome
- Open the browser task manager (Shift+Esc or Menu -> More Tools -> Task Manager)
- Find the tab in the task manager and see its memory consumption. It will be about 20-30MB.
- Download this
glbmodel with big 4K textures - Drag and drop the model on the viewer several times. You will see that the memory consumption rapidly increases, despite the fact all textures are disposed of each time
Expected behavior
The code texture.source.data.close?.() before texture.dispose() solves the problem.
But I would expect the Texture.prototype.dispose() method to do it automatically, especially given the fact, the textures are created by the gltf loader, and their type isn't obvious. Alternatively, a bool flag deep=true can be passed to the method to dispose of the inner resource.
If it's by design, it should be clearly written in the documentation.
Platform:
- Browser: Chrome
- Three.js version: r139
Mugen87elalish