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’re making changes to the Unity Runtime Fee pricing policy that we announced on September 12th. Access our latest thread for more information!
    Dismiss Notice
  3. Dismiss Notice

Memory Leaks?

Discussion in '2017.2 Beta' started by sonicviz, Jul 10, 2017.

  1. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,051
    Hi,
    Using the latest beta on PC Desktop and it seems to eat ram compared to previous beta.
    When I open my working project I have about ~50% ram used on an 8gb system.

    After a few runs of scenes in the editor it gradually maxes out the ram and kills my system.

    Any clues?
    Is there any way to restrict Unity editor to use a maximum amount of ram?

    ty.
     
  2. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,394
    AbhishekRaj and faximegames like this.
  3. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,051
    No, this is different I think. I wasn't searching afaik. I'm not sure what the trigger is for this, but it seems to occur after playing a scene a few times. Maybe a leak when running, but not getting released on stop?

    In addition to this memory hogging leak the new package manager spooling up a node.js server is also consuming more resources. This is a good idea to be on by default, there should be some option to turn these components on and off by request. This is important when developing on systems that need ram. Not every one has a 32gb ram top of the line machine.

    Previously I've never had problems running unity editor, Visual Studio, and a browser open.
    Now I'm getting my memory eaten like crazy and it's really impacting development.
     
  4. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,051
    I've discovered what the problem is that's causing it.

    It's something to do with the UI.
    Initially I thought it only occurred when I showed my UI in play mode (via the space bar), as every time I did I could see the windows task manager memory start growing for Unity.exe

    But I just discovered it also happens in normal editor mode, no doubt due to Unity's preview mode.
    I had my UI panels up and was editing them and noticed the Ram was going through the roof.

    This is a showstopper. Surely others are noticing this?

    Pretty certain this is b2 related as I don't recall such issues with b1.
     
  5. Alex-Lian

    Alex-Lian

    Guest

  6. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,051
    Thanks for the update. Looking forward to the fix!

    Edit:
    It says "Fixed in Unity 2017.1" but I'm using Unity 2017.2.0b2 and it's in that.
    I submitted a bug report (Case 928496) Unity2017 b2 Ram Eater
     
  7. Ironmax

    Ironmax

    Joined:
    May 12, 2015
    Posts:
    890
    1 factor is to blame the engine, 2. factor is to check your own codes for allocation. Are you allocating in update etc?
     
  8. Alex-Lian

    Alex-Lian

    Guest

    Our "Fix" means it's fixed in development, but not yet pushed and verified to a release branch.
    The in-version is just the where it was logged against and targeting to fix.

    It's actually also not landed to 2017.1 either, it's in a dev branch on way to 2017.1.
    While we do our best to avoid the latency of having a fix put everywhere, there is some gap in making sure it's in all places.
     
  9. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,051
    @Alex Thanks for the clarification

    @Ironmax Initially I thought the problem may be caused by a UI package I was using (https://www.assetstore.unity3d.com/en/#!/content/54552) but after I refactored and removed it I noticed the Ram getting eaten while I was editing the normal UI. I wasn't in play mode and it's just a test harness UI with sliders etc for rapid prototyping settings changes when in full screen (instead of using editor inspector), nothing fancy.
     
  10. Ironmax

    Ironmax

    Joined:
    May 12, 2015
    Posts:
    890
    Not sure if this is Editor only or not. but "Canvas.SendWillRenderCanvases" is allocating allot of memory. You can try to remove pixel perfect on your canvas and see if that fixed your issue.
     
  11. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,051
    Nope, no effect.
     
  12. Ironmax

    Ironmax

    Joined:
    May 12, 2015
    Posts:
    890
    Canvas system in Unity have been leaky for some time now since it was introduced.

    Try System.GC.Collect(); some where in your code to see if it changes any thing.

    lets say after 2 min.
     
  13. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,051
  14. Ironmax

    Ironmax

    Joined:
    May 12, 2015
    Posts:
    890
    yes its hacky, but its just to check if the leak comes from your own codes or the engine.

    But yeah its good they are adressing this.

    this issue it not only releted to Text.text set. also icon sprite change, or color change.
    basically any UI component..
     
  15. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    946
    There is no way for managed-side regular allocations to cause what he is seeing, the collector will trigger automatically when enough allocations have occurred, long before he ends up with his entire system running out of memory. His code could potentially allocate unmanaged objects or trigger the allocation of them, but GC.Collect() would have no effect whatsoever in that case. Resources.UnloadUnusedAssets() might but since Unity have confirmed this as a bug, I'd just wait.
     
    Last edited: Jul 11, 2017
  16. Ironmax

    Ironmax

    Joined:
    May 12, 2015
    Posts:
    890
    Managed code can cause leak, because the collector waits before it collects (specially the new one). But i agree in his case its highly unlikely. Lets just hope we get this fixed soon, canvas is the only thing i have issue with when it comes to memory.
     
  17. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Anyone finding when "upgrading" importing project the CPU (MacOSX) goes crazy.. not a memory leak directly but I think it can be related, some optimisation on Unity and harmony with the OS is needed.
     
  18. tetriser016

    tetriser016

    Joined:
    Jan 3, 2014
    Posts:
    100
    I'm also having this problem, on the release version of 2017.1.

    The editor once killed my laptop each time I preview my project.

    I hope there's a solution for this.
     
    Last edited: Aug 19, 2017
  19. tetriser016

    tetriser016

    Joined:
    Jan 3, 2014
    Posts:
    100
    So, I've reverted to 5.6, although lost some new features. No memory leaks so far.

    So, it could be a bug in 2017.1 that's causing the memory leak.

    I hope it will be fixed ASAP.
     
    MrEsquire likes this.
  20. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,428
    We'll need a bug report for that.
     
  21. ubberkid

    ubberkid

    Joined:
    Mar 11, 2014
    Posts:
    17
    There's already a bug for it, and many other that are marked as duplicates. The only solution you guys have at the moment is to upgrade to the beta, which fixes the problem... except, you now have to deal with all the issues of the beta.. Would be nice to have a patch release fix for the 2017.1 version, instead of having to upgrade to a non stable version..

    Says it's fixed even though it's not..
    https://issuetracker.unity3d.com/issues/possible-memory-leak-for-development-mode-standalone
     
  22. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,428
    Thanks. I just looked at it and it's been reopened by QA a week ago (probably the issue tracker page just haven't caught up yet). Devs on the Input team are on it.
     
  23. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,276
    Is this fixed in 2017.2?
    I'm using 2017.1.0p4, and the canvas manager memory leaks isn't fun when searching in hierarchy. Have to restart Unity once in a few hours.
     
    Last edited: Sep 27, 2017
  24. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,102
    Yes, it's fixed in 2017.2.0f1.
     
  25. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,276
    Great, thanks!