Out of memory error when trying to import 3D models

Hello I have a problem with my program. My program imports 6 3D models from blender and works perfectly in my computer, but when I run it in my phone it displays an error saying “out of memory”. What can I do ?

Hello and welcome!

Well, this will probably disappoint you but:

  • either you have a memory leak
  • or your objects are just too large for your mobile

What is the overall scene size? How many meshes/vertices/textures ?

Welcome @Panda003! Awesome to have you as a part of the community!

Do you have a playground you could point us to to help troubleshoot?

yes follow this link and try it: Repl.it - The Memory Game
(If you don’t mind, please give it an upvote by creating an account and verifying it)

as I said, in computer it works perfectly, but when you start the game in mobile it displays an error.

Another thing, is there a way to make the sounds play on time, because when the buttons are pressed, the sounds take time to play.

I imported 6 models from blender plus 2 planes added to the scene.

yeah but are they 6 models of 3 faces or 3millions triangles? :smiley:

If you used the .babylon exporter, post your log files which have accurate stats.

1 Like

The .babylon exporter files are like this:

{“producer”:{“name”:“Blender”,“version”:“2.79 (sub 0)”,“exporter_version”:“5.6.4”,“file”:“button1_game_1.babylon”},
“autoClear”:true,“clearColor”:[0.0509,0.0509,0.0509],“ambientColor”:[0,0,0],“gravity”:[0,-9.81,0],
“materials”:[{“name”:“button1_game_1.Material.001”,“id”:“button1_game_1.Material.001”,“ambient”:[0.8,0.0073,0.0022],“diffuse”:[0.64,0.0058,0.0018],“specular”:[0.5,0.5,0.5],“emissive”:[0,0,0],“specularPower”:50,“alpha”:1,“backFaceCulling”:true,“checkReadyOnlyOnce”:false,“maxSimultaneousLights”:4}],
“multiMaterials”:[],
“skeletons”:[],
“meshes”:[{“name”:“Button 1 Game”,“id”:“Button 1 Game”,“materialId”:“button1_game_1.Material.001”,“billboardMode”:0,“position”:[0,0,0],“rotation”:[0,0,0],“scaling”:[1,1,1],“isVisible”:true,“freezeWorldMatrix”:false,“isEnabled”:true,“checkCollisions”:false,“receiveShadows”:false,“pickable”:true,“tags”:""
,“positions”:[-17.0933,7,3.2334,-17.2159,7,2.5,-10.0099,7,2.5,-7.1359,7,7.4514,-12.3009,7,12.3009,-7.4514,7,7.1359,-12.8154,7,11.764,-7.753,7,6.807,-13.3064,7,11.2057,-8.04,7,6.4654,-13.7731,7,10.6268,-8.3121,7,6.1117,-14.2146,7,10.0285,-8.5686,7,5.7466,-14.6302,7,9.4119,-8.8091,7,5.3707,-15.0191,7,8.7781
,-9.0331,7,4.9848,-15.3805,7,8.1283,-9.2402,7,4.5896,-15.7138,7,7.4637,-9.43,7,4.1858,-16.0184,7,6.7853,-9.6022,7,3.7741,-16.2938,7,6.0946,-9.7565,7,3.3554,-16.5394,7,5.3928,-9.8925,7,2.9305,-16.7547,7,4.6811,-16.9395,7,3.9609,-2.5,7,17.2159,-3.2334,7,17.0933,-2.5,7,10.0099,-3.9609,7,16.9395
,-2.9305,7,9.8925,-4.6811,7,16.7547,-3.3554,7,9.7565,-5.3928,7,16.5394,-3.7741,7,9.6022,-6.0946,7,16.2938,-4.1858,7,9.43,-6.7853,7,16.0184,-4.5896,7,9.2402,-7.4637,7,15.7138,-4.9848,7,9.0331,-8.1283,7,15.3805,-5.3707,7,8.8091,-8.7781,7,15.0191,-5.7466,7,8.5686,-9.4119,7,14.6302,-6.1117,7,8.3121
,-10.0285,7,14.2146,-6.4654,7,8.04,-10.6268,7,13.7731,-6.807,7,7.753,-11.2057,7,13.3064,-11.764,7,12.8154,-10.0099,2.5,2.5,-17.2159,2.5,2.5,-2.5,2.5,17.2159,-3.2334,2.5,17.0933,-3.9609,2.5,16.9395,-4.6811,2.5,16.7547,-5.3928,2.5,16.5394,-6.0946,2.5,16.2938,-6.7853,2.5,16.0184,-7.4637,2.5,15.7138,-8.1283,2.5,15.3805
,-8.7781,2.5,15.0191,-9.4119,2.5,14.6302,-10.0285,2.5,14.2146,-10.6268,2.5,13.7731,-11.2057,2.5,13.3064,-11.764,2.5,12.8154,-12.3009,2.5,12.3009,-12.8154,2.5,11.764,-13.3064,2.5,11.2057,-13.7731,2.5,10.6268,-14.2146,2.5,10.0285,-14.6302,2.5,9.4119,-15.0191,2.5,8.7781,-15.3805,2.5,8.1283,-15.7138,2.5,7.4637,-16.0184,2.5,6.7853,-16.2938,2.5,6.0946
,-16.5394,2.5,5.3928,-16.7547,2.5,4.6811,-16.9395,2.5,3.9609,-17.0933,2.5,3.2334,-2.9305,2.5,9.8925,-2.5,2.5,10.0099,-7.4514,2.5,7.1359,-7.1359,2.5,7.4514,-6.807,2.5,7.753,-6.4654,2.5,8.04,-6.1117,2.5,8.3121,-5.7466,2.5,8.5686,-5.3707,2.5,8.8091,-4.9848,2.5,9.0331,-4.5896,2.5,9.2402,-4.1858,2.5,9.43,-3.7741,2.5,9.6022
,-3.3554,2.5,9.7565,-9.8925,2.5,2.9305,-9.7565,2.5,3.3554,-9.6022,2.5,3.7741,-9.43,2.5,4.1858,-9.2402,2.5,4.5896,-9.0331,2.5,4.9848,-8.8091,2.5,5.3707,-8.5686,2.5,5.7466,-8.3121,2.5,6.1117,-8.04,2.5,6.4654,-7.753,2.5,6.807]
,“normals”:[-0.699,0.702,0.132,-0.627,0.569,-0.531,0.489,0.593,-0.64,0.486,0.712,-0.507,-0.503,0.702,0.503,0.507,0.712,-0.486,-0.524,0.702,0.481,0.528,0.712,-0.463,-0.544,0.702,0.459,0.547,0.712,-0.44,-0.564,0.702,0.435,0.566,0.712,-0.416,-0.582,0.702,0.41,0.583,0.712,-0.391,-0.599,0.702,0.385,0.6,0.712,-0.366,-0.615,0.702,0.359
,0.615,0.712,-0.339,-0.629,0.702,0.333,0.629,0.712,-0.312,-0.643,0.702,0.305,0.642,0.712,-0.285,-0.655,0.702,0.278,0.653,0.712,-0.257,-0.667,0.702,0.249,0.664,0.712,-0.228,-0.677,0.702,0.221,0.673,0.712,-0.199,-0.686,0.702,0.192,-0.693,0.702,0.162,0.531,0.569,0.627,-0.132,0.702,0.699,0.64,0.593,-0.489,-0.162,0.702,0.693
,0.199,0.712,-0.673,-0.192,0.702,0.686,0.228,0.712,-0.664,-0.221,0.702,0.677,0.257,0.712,-0.653,-0.249,0.702,0.667,0.285,0.712,-0.642,-0.278,0.702,0.655,0.312,0.712,-0.629,-0.305,0.702,0.643,0.339,0.712,-0.615,-0.333,0.702,0.629,0.366,0.712,-0.6,-0.359,0.702,0.615,0.391,0.712,-0.583,-0.385,0.702,0.599,0.416,0.712,-0.566
,-0.41,0.702,0.582,0.44,0.712,-0.547,-0.435,0.702,0.564,0.463,0.712,-0.528,-0.459,0.702,0.544,-0.481,0.702,0.524,0.489,-0.593,-0.64,-0.627,-0.569,-0.531,0.531,-0.569,0.627,-0.132,-0.702,0.699,-0.162,-0.702,0.693,-0.192,-0.702,0.686,-0.221,-0.702,0.677,-0.249,-0.702,0.667,-0.278,-0.702,0.655,-0.305,-0.702,0.643,-0.333,-0.702,0.629
,-0.359,-0.702,0.615,-0.385,-0.702,0.599,-0.41,-0.702,0.582,-0.435,-0.702,0.564,-0.459,-0.702,0.544,-0.481,-0.702,0.524,-0.503,-0.702,0.503,-0.524,-0.702,0.481,-0.544,-0.702,0.459,-0.564,-0.702,0.435,-0.582,-0.702,0.41,-0.599,-0.702,0.385,-0.615,-0.702,0.359,-0.629,-0.702,0.333,-0.643,-0.702,0.305,-0.655,-0.702,0.278,-0.667,-0.702,0.249
,-0.677,-0.702,0.221,-0.686,-0.702,0.192,-0.693,-0.702,0.162,-0.699,-0.702,0.132,0.199,-0.712,-0.673,0.64,-0.593,-0.489,0.507,-0.712,-0.486,0.486,-0.712,-0.507,0.463,-0.712,-0.528,0.44,-0.712,-0.547,0.416,-0.712,-0.566,0.391,-0.712,-0.583,0.366,-0.712,-0.6,0.339,-0.712,-0.615,0.312,-0.712,-0.629,0.285,-0.712,-0.642,0.257,-0.712,-0.653
,0.228,-0.712,-0.664,0.673,-0.712,-0.199,0.664,-0.712,-0.228,0.653,-0.712,-0.257,0.642,-0.712,-0.285,0.629,-0.712,-0.312,0.615,-0.712,-0.339,0.6,-0.712,-0.366,0.583,-0.712,-0.391,0.566,-0.712,-0.416,0.547,-0.712,-0.44,0.528,-0.712,-0.463]
,“indices”:[0,1,2,3,4,5,4,6,5,5,6,7,6,8,7,7,8,9,8,10,9,9,10,11,10,12,11,11,12,13,12,14,13,13,14,15,14,16,15,15,16,17,16,18,17,17,18,19,18,20
,19,19,20,21,20,22,21,21,22,23,22,24,23,23,24,25,24,26,25,25,26,27,26,28,27,27,28,2,28,29,2,2,29,0,30,31,32,31,33,32,32,33,34,33,35,34,34,35,36,35
,37,36,36,37,38,37,39,38,38,39,40,39,41,40,40,41,42,41,43,42,42,43,44,43,45,44,44,45,46,45,47,46,46,47,48,47,49,48,48,49,50,49,51,50,50,51,52,51,53,52
,52,53,54,53,55,54,54,55,3,55,56,3,3,56,4,2,1,57,1,58,57,30,59,60,30,60,31,60,61,31,31,61,33,61,62,33,33,62,35,62,63,35,35,63,37,63,64,37,37,64
,39,64,65,39,39,65,41,65,66,41,41,66,43,66,67,43,43,67,45,67,68,45,45,68,47,68,69,47,47,69,49,69,70,49,49,70,51,70,71,51,51,71,53,71,72,53,53,72,55,72
,73,55,55,73,56,73,74,56,56,74,4,74,75,4,4,75,6,75,76,6,6,76,8,76,77,8,8,77,10,77,78,10,10,78,12,78,79,12,12,79,14,79,80,14,14,80,16,80,81,16
,16,81,18,81,82,18,18,82,20,82,83,20,20,83,22,83,84,22,22,84,24,84,85,24,24,85,26,85,86,26,26,86,28,86,87,28,28,87,29,87,88,29,29,88,0,88,58,0,0,58
,1,89,61,90,61,60,90,90,60,59,91,74,92,74,73,92,92,73,93,73,72,93,93,72,94,72,71,94,94,71,95,71,70,95,95,70,96,70,69,96,96,69,97,69,68,97,97,68,98,68
,67,98,98,67,99,67,66,99,99,66,100,66,65,100,100,65,101,65,64,101,101,64,102,64,63,102,102,63,89,63,62,89,89,62,61,58,88,57,88,87,57,57,87,103,87,86,103,103,86,104
,86,85,104,104,85,105,85,84,105,105,84,106,84,83,106,106,83,107,83,82,107,107,82,108,82,81,108,108,81,109,81,80,109,109,80,110,80,79,110,110,79,111,79,78,111,111,78,112,78,77
,112,112,77,113,77,76,113,113,76,91,76,75,91,91,75,74,2,57,27,57,103,27,27,103,25,103,104,25,25,104,23,104,105,23,23,105,21,105,106,21,21,106,19,106,107,19,19,107,17,107
,108,17,17,108,15,108,109,15,15,109,13,109,110,13,13,110,11,110,111,11,11,111,9,111,112,9,9,112,7,112,113,7,7,113,5,113,91,5,5,91,3,91,92,3,3,92,54,92,93,54
,54,93,52,93,94,52,52,94,50,94,95,50,50,95,48,95,96,48,48,96,46,96,97,46,46,97,44,97,98,44,44,98,42,98,99,42,42,99,40,99,100,40,40,100,38,100,101,38,38,101
,36,101,102,36,36,102,34,102,89,34,34,89,32,89,90,32,30,32,59,32,90,59]
,“subMeshes”:[{“materialIndex”:0,“verticesStart”:0,“verticesCount”:114,“indexStart”:0,“indexCount”:672}]
,“instances”:[]}
],
“morphTargetManagers”:[],
“cameras”:[{“name”:“Camera”,“id”:“Camera”,“position”:[7.4811,5.3437,-6.5076],“rotation”:[0.4615,-0.8149,0],“fov”:0.8576,“minZ”:0.1,“maxZ”:100,“speed”:1,“inertia”:0.9,“checkCollisions”:false,“applyGravity”:false,“ellipsoid”:[0.2,0.9,0.2],“cameraRigMode”:0,“interaxial_distance”:0.0637,“type”:“UniversalCamera”}],“activeCamera”:“Camera”,
“lights”:[{“name”:“Lamp”,“id”:“Lamp”,“type”:0,“position”:[4.0762,5.9039,1.0055],“intensity”:1,“diffuse”:[1,1,1],“specular”:[1,1,1]}],
“shadowGenerators”:[]
}

I asked for the log file, since an actual .babylon file can be very large, but six of something this size is not that significant. Problem is probably not with the amount of geography.

That leaves your load code having a memory problem, or your phone is just a real dud. Here is a playground, https://www.babylonjs-playground.com/#XI2GQI which should load & have more geometry than your scene. It has a number of cylinders, but this can be increased and saved, if you wish.

When you run it from your phone, add a frame.htm into the url, so the editor is not loaded, like this:
https://www.babylonjs-playground.com/frame.htm#XI2GQI

If this does not have enough memory, it is likely your phone.

1 Like

Yea, I looked at the actual babylon files that get loaded through the browser, all pretty small. Also, works fine on my phone (Pixel 2)

Thank you Ill see if it works

And can you help me with the sounds ? I would like that they loaded faster

You are loading the audio as a new sound object every single time you play the sound.
You should be loading the sounds just once at the beginning and then playing them when needed, rather than loading a new one.

Regardless of that flaw, the sounds are pretty quick for me, but I think that that would be a performance booster for you.

I did it, but how do I remove the mute icon

at the top left

You cannot remove it. This is a constraint coming from the browsers. Audio must be started after an user action (like a click).

This is why we automatically add this icon for you (so the user can click it to enable sound). Like here:
https://www.babylonjs-playground.com/#DXAEUY#0

Oh ok thank you though

1 Like