Skip to content

GLTFLoader ImageBitMapLoader with Cache enabled causes memory leak #32986

@Shane-oo

Description

@Shane-oo

Description

When using the GLTFLoader with a glTF that has textures, and with the three.js Cache enabled its possible to make the memory consumption grow until the client runs out of memory.

This seems to be because when the texture is loader the URL is randomly generated, therefore a Cache hit will never happen.

First load (5 image-bitmaps created):
Image

Loading a different model:
Image

Second load of the helmet (10 image-bitmaps created):
Image

after many loads:
Image

I first observed this on mobile as it only takes a few model changes for the memory limit to be reached and for the site to crash.

Reproduction steps

  1. Using webgl_loader_gltf.html add line THREE.Cache.enabled = true;
  2. Load the Damaged Helmet and take a heap snapshot
  3. Load a different model e.g. the Cube
  4. Go back to the Damaged Helmet and take another heap snapshot, and see that the Cache map has grown in size

Screenshots

No response

Version

r182

Device

all

Browser

all

OS

all

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions