Muhammad Faizan Khan
Muhammad Faizan Khan

Reputation: 10551

Heap memory increasing in each page load in chrome

I am getting aw snap or sometimes not enough memory problem when I reload my WebGL page. I have a WebGL project which is empty (just a camera + light), developed in unity3d. I am reloading it, and profile its memory. enter image description here

As you can see that its load 1.2MB in the first load than 1281 MB in second then 1574 then 2160 and then get crash. I am amazed that why it is happening?

I searched and found that

Upvotes: 2

Views: 1321

Answers (2)

TheTimeSte
TheTimeSte

Reputation: 1

the problem

the webgl build runs fine on every desktop browser and firefox mobile, but crashes after 3 seconds when using chrome mobile or safari mobile with the "aw, snap" page.

the problem was the amount of RAM that the project was using for loading assets. i found that the main problem was loading the audio system.

when the game started the RAM usage quickly escalated from 300 MB to 1,3GB.

how i fixed

i had a background music 20 minutes long, i cut that to 5 minutes. click the music, then click override for webgl set the load type to Streaming set the quality to 1

with this workaround the RAM usage floats around 600 MB, this allows the build to run on mobile.

this is an example

EDIT

turns out that after ios 15.5 update everything runs fine.

Upvotes: 0

Muhammad Faizan Khan
Muhammad Faizan Khan

Reputation: 10551

One of Unity fellows told that when browser Dev Tool is open, each page reload will increment the memory: "

One point to note is that when profiling memory usage on page reloads in Firefox, make sure to have the Firefox web console (and debugger) window closed. Firefox has a behavior that if web console is open, it keeps the Firefox JS debugger alive, which pins all visited pages to be cached in memory, never reclaiming them. Closing the Firefox web page console allows freeing the old pages from memory

BUT

My testing suggests that it is true for Chrome but not for firefox. Firefox keeps increments the memory with each page reload no matter your Dev tools are open or close.

But my problem resolve in chrome (still question on firefox? I guess it the default behaviour of browser), after closing the dev tools memory is not incremented on chrome.

Upvotes: 2

Related Questions