# Node Materials are leaking strings

**URL:** <https://forum.babylonjs.com/t/node-materials-are-leaking-strings/60959>\
**Category:** Bugs\
**Tags:** nodematerial\
**Created:** [October 14, 2025, 10:12pm UTC](https://forum.babylonjs.com/t/node-materials-are-leaking-strings/60959 "2025-10-14T22:12:16Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex2](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/alex2/32/19545_2.png) [@Alex2](https://forum.babylonjs.com/u/Alex2)\
**Post date:** [October 14, 2025, 10:12pm UTC](https://forum.babylonjs.com/t/node-materials-are-leaking-strings/60959/1 "2025-10-14T22:12:16Z")

</div>

We’re seeing a problem with Node Materials leaking string values from the parsed shader code.

In these two playgrounds, we can see the memory climb very quickly when we do a reload, even though the previous material is disposed.

With Reload:

> **[Babylon.js Playground](https://playground.babylonjs.com/#1Y4OOQ%231)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL and WebGPU 3D scenes

Without Reload:

> **[Babylon.js Playground](https://playground.babylonjs.com/#1Y4OOQ)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL and WebGPU 3D scenes

It’s pretty stark, but what seems to be happening is that EngineStore is retaining these strings on the Window object.

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/a/e/ae3a1261a8c2c71fa9304b616677491d40bf942f.jpeg)

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/0/e/0e5c80adcb39eca83f6662783e065dcc0d26af92.png)

Is this a bug or are we missing a magic function to clean it up?

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [October 14, 2025, 11:10pm UTC](https://forum.babylonjs.com/t/node-materials-are-leaking-strings/60959/2 "2025-10-14T23:10:03Z")

</div>

This is expected as we store shaders (effects) so we do not need to recompile a shader twice (as compilation is quite slow).  
That being said if you do not want to waste memory for that, you can just call this:

```auto
engine.releaseEffects();

```

---

<div class="post-metadata">

**Author:** ![Alex2](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/alex2/32/19545_2.png) [@Alex2](https://forum.babylonjs.com/u/Alex2)\
**Post date:** [October 14, 2025, 11:20pm UTC](https://forum.babylonjs.com/t/node-materials-are-leaking-strings/60959/3 "2025-10-14T23:20:00Z")

</div>

> [@Deltakosh](#):
>
> `engine.releaseEffects();`

Our actual use case is closer to this, in which we’re loading a Node Material once and then cloning so we can use it in different ways across meshes. Even with this update, I’m still seeing memory leaking.

> **[Babylon.js Playground](https://playground.babylonjs.com/#1Y4OOQ%233)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL and WebGPU 3D scenes

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [October 14, 2025, 11:30pm UTC](https://forum.babylonjs.com/t/node-materials-are-leaking-strings/60959/4 "2025-10-14T23:30:04Z")

</div>

> [@Deltakosh](#):
>
> `releaseEffects`

yes you are totally right because we HAVE A FREAKING LEAK 🙂

Thanks mate for the ping. I will send a PR quickly to fix that crap !

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [October 14, 2025, 11:33pm UTC](https://forum.babylonjs.com/t/node-materials-are-leaking-strings/60959/5 "2025-10-14T23:33:35Z")

</div>

[Fix memory leak when manually disposing effects by deltakosh · Pull Request #17299 · BabylonJS/Babylon.js](https://github.com/BabylonJS/Babylon.js/pull/17299)

---

<div class="post-metadata">

**Author:** ![Alex2](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/alex2/32/19545_2.png) [@Alex2](https://forum.babylonjs.com/u/Alex2)\
**Post date:** [October 15, 2025, 12:09am UTC](https://forum.babylonjs.com/t/node-materials-are-leaking-strings/60959/6 "2025-10-15T00:09:52Z")

</div>

Can’t you even _pretend_ to be slow? 😉

Thanks so much!

ETA: using the link from the PR, it seems to have stabilized.

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/f/7/f7413091fa5e54f9683862c7dfc3ccd3b8cd56ef.png)

---

<div class="post-metadata">

**Author:** ![kzhsw](https://avatars.discourse-cdn.com/v4/letter/k/848f3c/32.png) [@kzhsw](https://forum.babylonjs.com/u/kzhsw)\
**Post date:** [October 15, 2025, 8:55am UTC](https://forum.babylonjs.com/t/node-materials-are-leaking-strings/60959/7 "2025-10-15T08:55:29Z")

</div>

Any luck with reference count + delayed cleanup, or weakmap

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [October 15, 2025, 4:18pm UTC](https://forum.babylonjs.com/t/node-materials-are-leaking-strings/60959/8 "2025-10-15T16:18:46Z")

</div>

You know what? I forgot I did ref counting for effects lol.  
We are even letting one frame to make sure you are not recreating the same shader before disposing the compiledEffect.

I simply forgot about it. Man, don’t get old…

---

<div class="post-metadata">

**Author:** ![Alex2](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/alex2/32/19545_2.png) [@Alex2](https://forum.babylonjs.com/u/Alex2)\
**Post date:** [October 15, 2025, 4:32pm UTC](https://forum.babylonjs.com/t/node-materials-are-leaking-strings/60959/9 "2025-10-15T16:32:58Z")

</div>

From our end, we can confirm that strings are no longer piling up even when we dispose the materials.

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [October 15, 2025, 5:00pm UTC](https://forum.babylonjs.com/t/node-materials-are-leaking-strings/60959/10 "2025-10-15T17:00:26Z")

</div>

excellent news!
