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

Bug Memory Leaks in beta

Discussion in '2022.2 Beta' started by DanielDickinson, Nov 23, 2022.

  1. DanielDickinson

    DanielDickinson

    Joined:
    Aug 4, 2013
    Posts:
    278
    Recently upgraded from 2022.1 to the beta & have been having some serious issues. After a few play sessions my performance degrades so much that I need to restart the editor. From profiler analysis it appears caused by semaphore.WaitForSignal. I take it this means I'm waiting on the GPU which has it's memory pretty well maxed out?

    I'm getting warnings at the end of each play sessions along the lines of -

    [Worker0] Internal: There are remaining Allocations on the JobTempAlloc. This is a leak, and will impact performance

    [Worker0] To Debug, run app with -diag-job-temp-memory-leak-validation cmd line argument. This will output the callstacks of the leaked allocations.

    Potential race-condition clearing GeometryJob fences

    Burst settings (Probably relevant) are as followed -
    - Enable Compilation On
    - Safety Checks Force On
    - Leak Detection Full Stack Trace (Expensive)
    - Jobs Debugger On
    - Use Job Threads On

    On a Windows Machine - DX12
    Issue found on version 2022.2.0b16, b15, b14

    The only references I could find to do with geometry fences are linked to Unitys legacy UI (Which I'm using). Also using UI Toolkit. Slowly switching stuff over.

    I was using compute shaders/buffers & burst jobs but have since disabled all personal instances in pursuit of tracking this down. Still getting the errors above though, which are so far my best lead.

    "run app with -diag-job-temp-memory-leak-validation cmd line argument. This will output the callstacks of the leaked allocations." Seems like my best bet to track this down, but I'm unsure how exactly to run the app through cmd with additional arguments.

    Any help, especially some more detailed instructions on how to run that cmd line argument, would be much appreaciated.

    Cheers,
    Dan
     
    mahdi_jeddi, Kokowolo and Onat-H like this.
  2. Onat-H

    Onat-H

    Joined:
    Mar 11, 2015
    Posts:
    195
    Kokowolo likes this.
  3. DanielDickinson

    DanielDickinson

    Joined:
    Aug 4, 2013
    Posts:
    278
    Defintitely getting occasional crashes too. Attached crash dump & log of the latest. Can provide more if it helps.
    For what it's worth, definitely seeing stability improvements over the beta patches. Keep up the good work!
     

    Attached Files:

  4. DanielDickinson

    DanielDickinson

    Joined:
    Aug 4, 2013
    Posts:
    278
    Hate to say it, but looks like DX12 was the issue. Swapped back to DX11 in editor & it runs like butter. No issues.

    I'm sitting on 3000 batches + a ton of custom compute + GPU instanced bullsh*ttery. I tried minimalising the scene & removing all the custom GPU stuff but the problem persisted, so we might be able to rule these out. I'm using both legacy GUI & UI toolkit too, so that probably doesn't narrow it down too much.

    Tried both forward & forward+. MSAA is definitely on. Maybe that helps? For now I'm just going to stick with DX11.
     
  5. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,136
    Hi @Llockham-Industries,

    Would you be able to submit a bug report with a reproducible for the memory leaks? I have shared the thread with the devs but it's not clear from the information here what causes the issue.
     
    DanielDickinson likes this.
  6. DanielDickinson

    DanielDickinson

    Joined:
    Aug 4, 2013
    Posts:
    278
    Hey, thanks for taking the time to respond!

    I've narrowed down the majority of the memory leaks to - StaticBatchingUtility.Combine creating meshes & not automatically cleaning them up when exiting play-mode. This is easy enough to do with Resources.UnloadUnusedAssets before the game ends but after the world tiles have been destroyed. I definitely expected this to happen automatically though. It seems this is by design? Not sure why but it's not too hard to get around.

    I was generating & batching 18km square terrains in 6km tiles every time I tested the game, so this leaked a lot very quickly. In comparison, the rest of the leaks I was getting errors for are fairly trivial & aren't slowing me down too much.

    I've just upgraded to the first release candidate, I'll check DX12 & report back if their are any issues.
    Again, thanks for taking the time to check in! Happy holidays!
     
    LeonhardP likes this.
  7. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,091
    Had this warning spam when using 1.0.0-pre4 AI Navigation, had to update to newest hidden version together with new Samples.
     
  8. Sulfield

    Sulfield

    Joined:
    Sep 17, 2014
    Posts:
    2
    Wow, didn't know multiple people had this problem. I filed a bug report 2 weeks ago, so far without any results, lets see
     
    mahdi_jeddi likes this.
  9. Yoyoyodog123

    Yoyoyodog123

    Joined:
    Sep 20, 2021
    Posts:
    1
    I received this too, is any way to fix it?