Memory Shootup after loading the scene in Babylon js

Hello Team Babylon JS Greetings,

We have a small issue which is regarding memory shoot-up. Scene is loading perfectly alright no issues with the scene but when we load the scene initially it is taking hell lot of memory to load. The scene file is hardly less than 30 MB, but while loading memory is shooting up-to 1 GB which is a problem to showcase in mobile devices.If i load all the other functionalities like adding light maps, videos and image sliders it is shooting up-to 3 GB. Can you please guide us so that we can load the scene with as less memory as possible…

Thank you

Attaching Images and playground link for your reference
images:
Before Scene Load
After Scene Load
Playground link:
https://playground.babylonjs.com/#2YWWIQ#13

Have you checked that it didn’t work on mobile?

As there is plenty of memory on a desktop, the memory consumption will grow more than on a mobile before the GC kicks in. On a mobile, the GC will kick in more often but that should still work (except if no memory can be reclaimed when the js system needs more memory).

Your scene is just around 170k tri, so I don’t think it’s the geometry.

Some of your textures are quite big and not in power of two sizes, you can start an easy optimisation here:


Example: the Image_16.jpg in my screenshot seems to be used only on the two little tables, you should try to reduce to 512px² or even 256px² maybe

1 Like

in iphone and ipad is throwing the error saying memory consumption is more

where can i find this tool …

I’m using XnView (MP version): XnView MP | XnView.com
To configure thumbnails details as me, you have to tweak the settings like this:

Note also the Batch Convert, which is basically the same as XnConvert, allowing you to batch some processes on an image list.

1 Like

I have one more question, when I have glb with textures, how importmesh function work, is it going import textures with nomips = true or nomips= false

I am assuming nomips = true will consume less memory

It depends on how your samplers are defined in the gltf file.

If you use minification filters that are either NEAREST or LINEAR, the mipmaps won’t be generated.

we are using maya exportor for gltf, where can i configure this ?

No idea, maybe @PatrickRyan will know.

maybe @PirateJC as well

I don’t believe you have access to setting those properties in the Maya exporter from what I can tell.

Bringing in @bghgary to see if he might now.

@Drigax might know for Maya

Besides the issues that other people have already mentioned, this asset also has some inefficient usage of textures. There are a bunch of (I count 16) 1024x1024 solid color images in the asset that shouldn’t be using textures at all. These will get expanded into a 1024x1024 on the CPU so that it can get uploaded to the GPU when it doesn’t need to at all since it’s solid.

@sai_chaitanya, @Krishna_Kishore I’m not too sure if we’ll get much benefit from asset optimization… Some preliminary analysis looks like the scene is using an appropriate amount of memory after loading completes:

Is this only happening with this specific scene? or are you noticing memory spikes when loading any glTF?

we tried optimizing the assets no luck as you send, this is happening to some of our scenes we created, glb files hardly 30 MB but memory is consuming , what we observed when ever we apply the light maps the memory is shoot up

can you please guide us on texture selection, any guidance on the textures

I’m seeing 84 textures from your file,
some are not power of 2,
some are very big, 4096, 2500, 1024
many wall textures are 1024x1024 solid single color textures

I suggest you go through your textures and ask for each,
Is it power of two?
Textures which are not power of 2 will be roofed to nearest power of 2 on the GPU, 1194x862 becomes 2048x2048.
Can it be reduced in pixel size?
Many times, there’s no need for 1024px textures. Often 512 is enough if it’s not a large model, even 256 for smaller models
Can it be replaced by a solid color?
I see solid 1024px wall textures, can these be replaced by colors? or are they placeholders?

I also note multiple textures for wall posters, the actual textures are half-texture poster images, and other half is solid color, can some of these be combined? 1 texture for 2 posters?

1 Like

@Drigax as you mentioned memory consumption is because of not textures, it is some thing else, can you please help to find the cause.

Could it come from some meshes with many vertices? They aren’t look huge to me, but maybe this occur when the engine parse the vertex buffer for each mesh or something like that?

image

Maybe it could come from some code in your app? In sandbox the .glb seems to load normally.

may be let me rephrase my question,

i have model which is just 10 MB.
please find the model in the url below

https://3dspaces.blob.core.windows.net/spaces/demos/aparnapoc/MainMap.glb.

when we load this model in babylon scene which is in playground, it is taking almost 1GB of RAM, i just want to know why it is taking almost 800 MB of memory considering 200 MB is taking by default by browser , is there some thing we are doing wrong in modeling, is it expected behavior

https://playground.babylonjs.com/#2YWWIQ#15