Capítulo 819 de 859
Authoritative rules for when and how to free three.js's underlying GPU resources (buffers, shader programs, textures, framebuffers) via each class's own dispose() method, since three.js has no way to know an object's lifetime on its own.
BufferGeometry.dispose(): frees the WebGLBuffer created per attribute.Material.dispose(): only actually frees the underlying shader program once every material sharing that program has been disposed, since three.js reuses compiled programs where possible.Texture.dispose(): separate from material disposal, since one texture can be shared by multiple materials; frees the WebGLTexture.ImageBitmap.close(): must be called by the application itself for ImageBitmap-sourced textures — three.js can't auto-close it since the bitmap might still be used elsewhere.WebGLRenderTarget.dispose(): frees its texture plus the associated WebGLFramebuffer/WebGLRenderbuffer.Skeleton.dispose(): frees skeleton resources; only call it once no other skinned mesh shares that skeleton.renderer.info: exposes live counts of cached geometries, textures and programs — useful for spotting leaks.Controls and renderer instances, which cannot be used again after dispose().dispose() method itself.Controls and renderer instances, which become unusable after dispose().renderer.info reports live cached-object counts, a practical way to check for leaks.ResourceTracker pattern automates calling these same dispose() methods across a loaded object hierarchy.