efxlab Posted February 7, 2018 Share Posted February 7, 2018 Hello, I load a Glft model with a loader https://bin.fuelphp.com/snippet/view/OI and later with a HTML button I change the model in the same scene with a dispose (to remove it) and reload the new. The issue is that it seem memory is not released from the previous model, on iPad tablet for exemple, the scene become very slow. After several disposes and loads safari crash out of memory. Maybe Am I wrong with the mesh capture : loader.onMeshLoaded = function (mesh) { actualMesh = mesh; }; any idea ? Quote Link to comment Share on other sites More sharing options...
Guest Posted February 7, 2018 Share Posted February 7, 2018 I guess this is because your gltf is loading multiple mesh so you have to keep a list of them In your case you are storing only the last one You can call scene.debugLayer.show() to get an UI to get the list of meshes Quote Link to comment Share on other sites More sharing options...
efxlab Posted February 8, 2018 Author Share Posted February 8, 2018 Hey, it fine now for mesh release, but for Material ? I see in debug that at each load it store material in memory on a new GLFT load, How I can access and dispose ? I use GLFT format so its PBRMaterial ? I tried that but it no work : for(var i=0, len=activeMeshes.length; i < len; i++){ activeMeshes.dispose(); activeMeshes.PBRMaterial.dispose(); } How I can access to PBRMaterial from a GLFT loader ? thanks Ok on loader I can access to materials : loader.onMaterialLoaded = function (material) { }; Quote Link to comment Share on other sites More sharing options...
Amarth2Estel Posted February 8, 2018 Share Posted February 8, 2018 Hi efxlab ! BABYLON.Mesh has no attribute PBRMaterial but a single attribute material to deal with StandardMaterial and PBRMaterial. You can get material directly this way and dispose it (it will dispose the material only) Moreover, there is parameters in the method dispose of Material to force disposing its textures. The same way, there is parameters in the method dispose of Mesh to dispose its material (if exist) as well. Here is a PG showing these 2 solutions : https://www.babylonjs-playground.com/#10D6YT#77 With solution 1, textures are still in memory. With solution 2, disposing meshes cleans also all the now unnecessary data. efxlab 1 Quote Link to comment Share on other sites More sharing options...
efxlab Posted February 8, 2018 Author Share Posted February 8, 2018 Hello Amarth2Estel ! its perfect great just tested. Just for info, I will : mesh.dispose(false, true) instead of true/true, for recurse release on the mesh's children. Amarth2Estel 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.