Search code examples
unity-game-engineunity-webgl

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


Solution

  • 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.