Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

WebGl Profiler - please explain why this OOMd

Discussion in 'WebGL' started by levwsr, Nov 18, 2015.

  1. levwsr

    levwsr

    Joined:
    Jul 23, 2012
    Posts:
    68
  2. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    If i read it correctly, your Unity Heap size (WebGL Memory Size) is set to 176 and you are exceeding that with the next allocation. Any idea about what's being allocated at the time of the crash ?

    Can you try to profile memory with a larger Unity Heap to see if memory usage increases at that point ?
     
  3. levwsr

    levwsr

    Joined:
    Jul 23, 2012
    Posts:
    68
    We are loading a NGUI screen from a bundle / prefab, which probably has a bunch of allocations (all small) related to it. The bundle is already loaded and other things were pulled from it at this point.

    Memory is constantly going up and down each time you load screens, but with no obvious leak. Which of these numbers should i be watching, and what "adds up to 185mb and is a problem"? There are a lot of numbers on this screen.
     
  4. levwsr

    levwsr

    Joined:
    Jul 23, 2012
    Posts:
    68
    in fact, the same screen was already loaded and the whole game loop has already been played multiple times at this point.
     
  5. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    I just noticed from the screenshot, "Reserved Total" is higher than "Used Total" which means at some point the memory consumption spikes to 129ms (actually more considering you are running OOM), so your Heap must be at least as big as that.
    So, I would suggest to give it more memory (let's say 256mb), play through the game, then take "Reserved Total" as an indication to lower the Unity Heap size again.

    something I should mention is that I suspect both UsedTotal and ReservedTotal don't account for all memory used so you might need to allocate a bit. This is something I am currently investigating...
     
  6. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    Even when we track all allocations correctly, it is very possible to have less used memory then your heap size, and still run out of memory - when memory fragmentation prevents allocating a block of the required size.
     
  7. levwsr

    levwsr

    Joined:
    Jul 23, 2012
    Posts:
    68
    @jonas echterhoff - having done a lot of console games with very limited memory, im familiar with wrestling with fragmentation issues. I was hopeful that would not be the case here, but based on your comments above is suspect its exactly the problem. We could have 20 megs free but no room to allocate a 4mb texture if memory is allowed to frag. Especially with the small allocation behavior of lists and such.

    If we really want to solve this, we are going to need to be able to ask the memory allocator things like "whats the largest allocation you have avail", the same way you can interact with malloc.

    Is there any strategy being used by unity to clump small / tiny allocations into 1 area, leaving room for medium allocations and large allocations in other regions of the 200MB of mem we request?
     
  8. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    Yes, we use different allocation patters for different data types and sizes (which in general helps with issues like this, they would be worse if we did not do this). Non of this is user-configurable, however.
     
  9. levwsr

    levwsr

    Joined:
    Jul 23, 2012
    Posts:
    68
    Thats ok, but can you expose some sort of status dump so we can troubleshoot this? Even if its just something like LogMemStatus().

    Right now we keep crashing OOM for no reason we can diagnose.
     
  10. levwsr

    levwsr

    Joined:
    Jul 23, 2012
    Posts:
    68
    Yes, but we are asking (and running out) at 200MB+ now, which is 75MBs more than the reserved. Am i missing something?