How to dispose a texture from the renderer - increases with replacement of texture

In three js I’m seeing WebGL out of memory errors on my iOS devices.
The web-app runs ok on various other OSs and browsers e.g. Windows/Linux/MacOS, Firefox/Chrome/Safari, but maybe the problem is just hidden, and exacerbates on the weaker iOS devices.

I saw this link. In my case the number keeps growing with every image.

Is this ok, or should I dispose the previous texture? If yes how?
In the rendered scene I see only one Sprite object with single material image texture.


Without more context it’s hard to recommend something. Consider to demonstrate the memory leak with a live example.

That said if you don’t need a texture anymore, call dispose() on it.

I created an example. (it plays in Chrome)
In the console, grows with every added image.

According to here indicates the number of “Textures in Memory” ?
In my case, I don’t need to keep previous textures in memory.

I also found this link which:

  • disposes the geometry and the texture of the object before removing the object from the scene, and
  • disposes the renderLists

But still grows…