Potential memory leak when disposing GreasedLine

Hi everyone,

Please see here: Babylon.js Playground

After a few seconds there will be 5 extra materials. N.B. force dispose of material via mesh.dispose(false, true) has no effect on material dispose.

Not sure if I am doing sth wrong or whether my expectations are wrong. But I would expect if I let Babylon handle material creation/assignment it also handles cleanup.

N.B. I tried to fix it myself using “createAndAssignMaterial: false”; see https://playground.babylonjs.com/#HWJ3A1#1 But no success :pleading_face:

Best wishes

//Oops, sorry, wrong category. Moved it.

As a reliable workaround one may use line.material.dispose() before disposing the line itself.
Example - https://playground.babylonjs.com/#HWJ3A1#3


Nice! Works like a charme, thanks @labris :slight_smile:

1 Like

This PR will fix the problem: