Skip to content

Huge memory leak in v2.0 #286

@lekzd

Description

@lekzd

Hi there, I found a bug with shader materials caching that leads to the accumulation of large data collections stored in program uniforms

Steps to reproduce:

  1. create SplatRenderer and load first scene via SplatMesh
  2. dispose SplatRenderer and SplatMesh
  3. look at heap memory dump and observe big amount of data inside programMaterial var
  4. repeat 1..3 to observe memory leak

minor code change WeakMap -> Map do this issue, as I can see

in master branch we can see

const programMaterial = new WeakMap<DynoProgram, THREE.RawShaderMaterial>();

in v2.0.0-preview branch:

const programMaterial = new Map<DynoProgram, THREE.RawShaderMaterial>();

code here

Also

SplatAccumulator.generatorProgram Map is a static link that never cleaned up. I can clear it using direct SplatAccumulator import, but I think it can be good to see it in dispose method too.

code here

I can make a PR to fix theese issues as well in case of it will not brake anything

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions