[BUG] Memory leak · Issue #405 · enable3d/enable3d · GitHub
Skip to content

[BUG] Memory leak #405

Description

@psociety

Version: v0.26.1
Browser: Brave (also tried on Edge)
Bug: Taken RAM keeps piling up which forces me to close and open a new tab every few reloads.

This problem can also be observed on https://enable3d.io/ . Just open the browser task manager and reload the page. +200mb will pile up on every reload.

2025-10-13.12-19-07.mp4

I've tried adding a destroy event listener and do stuff like:

      onSceneDestroy() {
            while (this.third.scene.children.length)
            {
                this.third.scene.remove(this.third.scene.children[0]);
            }
            this.disposeSceneResources(this.third.scene);
    }
    
   disposeSceneResources(scene) {
    scene.traverse((object) => {
      console.log(object.name);
      // Dispose geometry
      if (object.geometry) {
        object.geometry.dispose();
      }

      // Dispose materials and associated textures
      if (object.material) {
        const materials = Array.isArray(object.material)
          ? object.material
          : [object.material];

        materials.forEach((material) => {
          // Dispose textures
          for (const key in material) {
            if (material[key] && material[key].isTexture) {
              material[key].dispose();
            }
          }

          // Dispose material itself
          material.dispose();
        });
      }
      if (object.texture) {
        object.texture.dispose();
      }
    });
  }

But the geometries & textures never go down :(
I'm using https://github.com/threlte/three-inspect to see the gemotries & textures count.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions