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.
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.