Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[M1 native] Profiler says 'The system is running out of memory' then shows 11GB available

Discussion in '2021.2 Beta' started by anatolyV, Oct 19, 2021.

  1. anatolyV

    anatolyV

    Joined:
    Nov 29, 2014
    Posts:
    63
    Hi, not sure if this is a bug or whether this is the intended behaviour but I'm unable to use the profiler unless I kill literally everything but Unity, on an 16GB RAM M1 machine. I'm attaching a screenshot of the message, it shows that it detects a fair bit of RAM/swap being available still, showing 62% used with about 11GB available. Memory pressure in Activity Monitor is yellow at the time and profiler won't work unless it's green. I do have a fair bit of stuff open and I'm okay killing Photoshop and such but having to quit Rider, Safari, etc. is a hassle every time I need to profile. Any ideas?

    This is on 2021.2.0b16.
     

    Attached Files:

  2. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,431
    Hello :),

    That 11GB is the theoretically available memory if nothing else is running on the machine. What does Activity monitor say is available around that time? The Profiler is reacting to the Memory Pressure warning so if Activity monitor shows it as yellow, that probably coincides with Unity getting the warning. If there really is nearly no free RAM available at that time because it is taken up by other apps, the Profiler behavior to drop frame data is the correct one. If not, maybe the pressure warning is a bit overly sensitive here? That could be a bug angle to look at but it'd also mean we'd have to somewhat ignore the warning the OS gave us.

    The other questions here is, why it is eating up this much memory? To triangulate that:
    1. If you go to Preferences > Analysis > Profiler > Frame Count, is it set to something higher than 300 and if not, does it get better if you set it to just 300?
    2. Are you deep profiling and is it better when you're not deep Profiling?
    3. If you close Profiler modules that you don't need currently (e.g. the audio, UI, Physics,...) And only readd them when you need more details on them, does it get better?
    4. Are you profiling Playmode, Editor or a build?
     
  3. anatolyV

    anatolyV

    Joined:
    Nov 29, 2014
    Posts:
    63
    Hi, thanks for the response. Yeah I understand that the total number is theoretically available memory/swap and I do feel it's being oversensitive somewhere. I find that MacOS is pretty good at RAM management and swapping, so it's not uncommon to see the system working well even at high pressure moments (it seems to just increase the swap size). For example at the same time Unity is refusing to profile, I can open up Photoshop or another RAM-hungry app and eat up an additional 7-8 gigs, and the system is fine and responsive. Might go in the red for a bit while it puts some of Safari's stuff on the SSD, but nothing the user would necessarily notice.

    My profiler is set to 300 frames, I'm not deep profiling, and it still does it if I only leave the CPU module active. I'll also attach a couple of screenshot of the Activity Monitor's top RAM users and RAM state in general. This would be bad on a system that doesn't swap as efficiently as MacOS does but even with hungry apps other than Unity, it's generally absolutely fine. And I do have around 90GB available on the system SSD so swapping out large amounts shouldn't be an issue. Might it be a good idea to have a hidden toggle somewhere to ignore the system's first ('yellow') memory warning, even if just for a test?

    Then again I do get that my RAM is well used and abused lol, but from other apps' behaviour in the same situation I feel the system can take it.
     

    Attached Files:

    Last edited: Oct 20, 2021
  4. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,431
    Apologies for the long silence but, could you please report a bug on this? I feel like we should investigate and maybe alter the behavior on M1...