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

Question Strange Memory leak on 2022.3.x

Discussion in 'Windows' started by commonblob, Jul 13, 2023.

  1. commonblob

    commonblob

    Joined:
    Apr 24, 2015
    Posts:
    20
    Hi all,

    So this is an odd one. My game when run on 2021.3, memory sits around 1.3GB on launch. However, ive had reports since making changes over the last couple of months that some users are seeing around 10GB.

    I got one user to do a memory capture with the Unity 2022.3.4f1 memory profiler, and it shows memory usage at around 1.6GB, however his task manager claims it is using 10GB.

    Im guessing that this is because the leak is outside of my code. Is there anyway to track this leak?
    My external DLLs that I use are Steam Audio (already tried downgrading this), Steamworks SDK 1.57 (already tried downgrading this too).

    He also ran it once and it didnt leak memory.
    Just not quite sure how to deal with this, I guess I could try downgrading to 2021.3 again, but that would mean rewriting my navmesh stuff and a few other bits, which isnt ideal.
     
  2. commonblob

    commonblob

    Joined:
    Apr 24, 2015
    Posts:
    20
    0 changes to code
    Changed version to 2021.3.28f1
    Recompiled
    Memory leak gone.
    Guess that settles what version im sticking on for a while!
     
  3. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,522
  4. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,232
    Were you using the 1.0 (or 1.1.0-pre.1) version of the Memory Profiler package to look at a a capture from a 2022.3 Player? Because that should get all committed memory reported from the OS. Native plugin memory would show up as Untracked, but it should all be accounted for as part of the committed memory, even if there isn't much more info. (2023.1+ can break even that untracked amount down a bit further and help provide some context for what that is. For more details see this blog post and the forum thread it links to and please ignore the mentioning of 2022.2+ captures having that extra data, that's a mistake in the blog post that still needs fixing)

    So Total Committed should at least be as much as what Task Manager says and Process Explorer could help break down a bit more what kind of residency status that memory is made up of.

    Beyond that, the tool that @Tautvydas-Zilys mentioned then should give you even more detail on that untracked memory.
     
  5. LunarBullet

    LunarBullet

    Joined:
    Jul 22, 2020
    Posts:
    4
    when i have two game windows the game ram goes crazy, like unity starts growing from 1gb to 5 gb to 10 to then 16 to then crashing my system lol, cant have two game windows at the same time
     
  6. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,232
    @LunarBullet when you say two Game Windows, do you mean Game Views in the Editor, or two windowed Standalone Player instances?

    Also, have you tried to take a memory snapshot of this? If it is growing out of control too quickly, you could use the MemoryProfiler.TakeSnapshot API to trigger the capture from code.

    Or have you tried using the Windows Performance Analyser that Tautvydas mentioned?

    And: does it also leak with just one, but slower?
     
  7. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    770
    I found “the” memory leak on 2022.3.x. I don’t know if its the same one as the OP but its been around since 2022.1 beta and I am surprised nobody has noticed it.

    I posted about it here: https://forum.unity.com/threads/2022-3-9-uielements-memory-leak.1491019/

    Is it possible to launch a production ready game with this type of memory leak? I never have had to experience this before but it seems extremely bad. It makes safari on webgl crash quickly.
     
    Last edited: Sep 12, 2023
  8. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,232
    No. I mean, there are ways to mitigate this by not instantiating new UI into a UIDocument continuously but that's less than ideal. BUT, thankfully you don't have to.

    Because this bug has already been fixed in 2022.3.10f1 and was tracked under UUM-46520
     
    MousePods likes this.
  9. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,232
    I'm also quite certain that this was not the same issue as what this thread was originally about.
     
  10. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    770
    Dang :(. That is good and bad news then. I hope the OP figures out their issue but at least its one less leak they surely have. Thanks!
     
    MartinTilo likes this.
  11. TwoYen

    TwoYen

    Joined:
    Oct 17, 2017
    Posts:
    2
    I am having the exact same problem. When I Drag out the Scene view or the Game view or any view actually, thus having "2 windows", or even when I splitscreen the scene and game view in the same window. The RAM bumps up rapidly and crashes my computer.

    I am fairly sure this happened after updating from 2021.3.25f1 to 2022.3.8f1

    edit: I've just read that something got fixed in 2022.3.10. I'll try that out right away.

    edit2: Yep that fixed it.
     
    Last edited: Sep 28, 2023
    MartinTilo likes this.
  12. paavann

    paavann

    Joined:
    Nov 21, 2018
    Posts:
    33
    @TwoYen were you getting the same issue I have mentioned on this thread, please let me know. I have been stuck on this since weeks and do not know how to fix this. Please confirm that mine issue is same as yours and which got fixed by upgrading Unity to 2022.3.10f1.
    Thanks
     
  13. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,232
    I doubt they are related.