Skip to content

WebGPURenderer: Memory Leaks #32409

@querielo

Description

@querielo

Description

Right now it’s too hard to clean memory of meshes, even if the user explicitly disposes geometry, materials and textures and remove all references.

The reason is:

  • A mesh “does not know” with which materials it was rendered (scene.overrideMaterial)
  • Each PassNode / override material can create one or more RenderObjects behind the scenes.
  • Those RenderObjects can only be destroyed when the corresponding material is disposed.
  • As a result, it’s not enough to dispose just the resources (geometry, materials, textures).
    You must also dispose all nodes that use overrideMaterial (including LightNode and PP nodes), or RenderObjects will stay alive and keep meshes strongly referenced.

It would be great to have a way to notify Renderer that a mesh is no longer needed, so it can remove all RenderObject instances associated with that mesh (mesh.dispose?)

Here is a video explanation from this PR: #32395 (comment)

output2.mp4

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions