Memory leak in babylon file loader

We have an app where we construct multiple scenes and destroy them. While investigating a memory leak, I found an issue that seems that all materials loaded via the babylon file loader are stored in a global object: Babylon.js/babylonFileLoader.ts at master · BabylonJS/Babylon.js · GitHub. These references retain the scene itself and causes big memory issues for our app.

Would it make sense to refactor this to use a WeakMap on the passed in Scene?

Great catch!

That’s an interesting issue. having a “temp” object not clear when needed should be fixed as soon as we can.

@bghgary - do you want to take over?

@ghempton Nice catch !!!

Here we are: Fix memoryleak by deltakosh · Pull Request #12585 · BabylonJS/Babylon.js (github.com)

1 Like

Wow you guys are fast! :slight_smile: Thanks for building such an awesome platform

3 Likes