Closed Lafeu-p closed 3 months ago
The three.js onDispose
function is only added once a tile has been rendered and there are WebGL resources to dispose of. It is not a problem if it has not been added.
You'll have provide a more concrete example of a memory leak or show where dangling references are left once a tile has been disposed. Javascript is a garbage collected language so it's expected that resource usage goes up until the GC runs.
LRUCache starts to dispose the tiles
Cleaning up geometry, material, and texture with the above code looks good, but I found that I was loading large 3dtiles with memory that kept increasing and LRUCache's caching strategy seemed to fail.
geometry.dispose () will call onGeometryDispose to clean the geometry contents, but this function will not be registered on the geometry if the mesh is not added (or was added) to the scene,because it traverses the object below the scene, gets the geometry of the object and then binds onGeometryDispose. Many tiles will not register onGeometryDispose after loading because the camera position has moved, and nothing will happen when the dispose function is called