mrdoob / three.js

JavaScript 3D Library.
https://threejs.org/
MIT License
102.81k stars 35.38k forks source link

Textures are not freed? #16800

Closed greggman closed 5 years ago

greggman commented 5 years ago
Description of the problem

Here's some code

https://jsfiddle.net/greggman/t1y8e3rq/

It creates a textured cube, renders once, then calls

  const loader = new THREE.TextureLoader();
  function loadTexture(url) {
    return new Promise((resolve, reject) => {
        loader.load(url, resolve, undefined, reject);
    });
  }
  const texture = await loadTexture('https://threejs.org/examples/textures/colors.png');

  const material = new THREE.MeshBasicMaterial({
    map: texture,
  });
  const mesh = new THREE.Mesh(geometry, material);
  scene.add(mesh);

  renderer.render(scene, camera);

  material.dispose();
  texture.dispose();
  geometry.dispose();
  THREE.Cache.clear();
  renderer.renderLists.dispose();

At the top I wrote some code to track WebGL resources. It shows that the textures were never freed. Am I supposed to do something else to see the textures get freed?

Three.js version
Browser
OS
greggman commented 5 years ago

Never mind. These are some internal textures three.js is allocating