About the Memory Leakage Problem of Babylonjs

As early as version 4.0, I have discovered that there is a memory leak problem, but now using version 5.0 still exists; But at the time, I couldn’t reproduce this error in Playground. The following is a snapshot of browser memory that I captured:

As long as I annotate this line, there will be no memory leak issues.

Obviously, it is caused by self luminescence。
I suspect that it is caused by self illumination and a large number of instances in the scene. There seems to be a conflict between them.

Have you tried with the latest version? I know that we have fixed a number of memory leaks since the release of version 5.0.

1 Like

It will be great to reproduce this in the playground, or in a deployed code where babylon is separable from the rest of the code.
Looking at the code, there is no reason not to clear this object when a mesh is disposed and it will probably fix the issue. However, the visibleInstances object is, in general, “self cleaning”, so it should be empty when the mesh is disposed unless certain conditions apply. Which might be the case when you turn on glow layer.

1 Like

This was created as draft - Clear internal instance containers in Mesh when disposed by RaananW · Pull Request #13685 · BabylonJS/Babylon.js (github.com), which should fix the issue in your case.

I will try.

1 Like

Hi! @zhang have you had a chance to test 6.0 and see if the memory problems have gone?