Skip to content

GPUComputationRenderer: Call dispose() on variable's material.#33318

Merged
Mugen87 merged 1 commit intomrdoob:devfrom
madisonrickert:fix/gpu-computation-renderer-dispose-leak
Apr 3, 2026
Merged

GPUComputationRenderer: Call dispose() on variable's material.#33318
Mugen87 merged 1 commit intomrdoob:devfrom
madisonrickert:fix/gpu-computation-renderer-dispose-leak

Conversation

@madisonrickert
Copy link
Copy Markdown
Contributor

@madisonrickert madisonrickert commented Apr 2, 2026

Summary

GPUComputationRenderer.dispose() disposes render targets and the pass-through shader material (via quad.dispose()), but never disposes the ShaderMaterial instances created for each computation variable.

These materials are allocated in createShaderMaterial() (called from addVariable()) and stored on variable.material, but dispose() never calls variable.material.dispose(). The ShaderMaterial objects and their associated WebGL programs are never released.

Fix

One line: variable.material.dispose() inside the existing variable loop.

How I found this

I work on a project that uses GPUComputationRenderer for a GPU-computed wave simulation. The app has a router that creates and destroys renderer instances on navigation. After switching between views repeatedly, GPU memory climbed steadily — the undisposed variable ShaderMaterial objects were accumulating.

Same fix submitted to three-stdlib: pmndrs/three-stdlib#428

…se()

ShaderMaterials created by createShaderMaterial() for each variable are
stored in variable.material but never disposed. The existing
quad.dispose() call disposes the passThruShader via the mesh, but the
per-variable materials and their WebGL programs are never released.

Same fix submitted to three-stdlib: pmndrs/three-stdlib#428

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Mugen87 Mugen87 added this to the r184 milestone Apr 3, 2026
@Mugen87 Mugen87 merged commit 582a03b into mrdoob:dev Apr 3, 2026
9 checks passed
@Mugen87 Mugen87 changed the title fix: dispose variable ShaderMaterials in GPUComputationRenderer.dispose() GPUComputationRenderer: Call dispose() on variable's material. Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants