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

2017.2: (Case 939424) "Shared UI Mesh" memory leak

Discussion in '2017.2 Beta' started by Peter77, Aug 6, 2017.

  1. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,618
    Animating a RectTransform causes that memory usage of a mesh called "Shared UI Mesh" infinitely grows. This memory leak is present in the editor and player. Please see the video attached to the bug-report.

    Here is a profiler screenshot of the submitted example after running for about 5 minutes. "Shared UI Mesh" increased from less than 1 mb to more than 700 mb.
    profiler_screenshot.png

    Reproduce
    • Open user project
    • Press File/Build & Run
    • Start generated .exe file, choose 640x480, Windowed mode and press "Play!"
    • Connect the Unity Profiler to the running Player
    • Select the Memory tab in the Profiler
    Observe in the bottom panel that "Meshes" memory usage grows

    • Switch Profiler to "Detailed" view
    • Press "Take sample"
    • Expand "Not Saved/Mesh" node
    • Write down Memory of "Shared UI Mesh"
    • Continue to run player for a minute
    • Press "Take sample"
    Notice "Shared UI Mesh" memory grew further.

    Expected
    Animating UI should not cause a memory leak.
     
    pcg likes this.
  2. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,618
    2017.2.0b6 fixed the leak in a build/player, but it continues to leak in the editor. I just submitted the following (update) bug-report that contains all the relevant data:
    (Case 940588) 'Shared UI Mesh' memory leak #2
     
    pcg and LeonhardP like this.
  3. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Again Excellent bug report and find Peter good work...
    Performance seems be real struggle with Unity testers
     
    Peter77 likes this.
  4. Carpe-Denius

    Carpe-Denius

    Joined:
    May 17, 2013
    Posts:
    842
    Any news? I don't know if there's a way to see the status of this case (or any bug).
    I don't think it is fixed yet, Unity still requires about 1mb of memory per second until it crashes.
     
  5. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,618
    The most recent reply I got from Unity Technologies is this:
    According to my own tests in 2017.2.0b6, the memory leak has been fixed in the player, but the editor is still affected by it. Haven't tested b7 yet.
     
  6. Carpe-Denius

    Carpe-Denius

    Joined:
    May 17, 2013
    Posts:
    842
    I still experience it in b7, but I didn't want to report it as a new bug if the old one is still open.
     
    Peter77 likes this.
  7. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,618
    It definitely a serious issue, which makes be believe Unity Technologies is going to fix it soon.
     
  8. Pelican_7

    Pelican_7

    Joined:
    Nov 25, 2014
    Posts:
    190
    I had to downgrade back to 5.6 from 2017.1 a few weeks ago after I discovered this.

    I thought it's worth saying that this memory leak issue related to UI rect transforms is also present in Unity 5.5 and 5.6. For anyone else who has projects that require these versions of Unity, make sure you get the patch releases that fix the issue.

    For 5.5 users, the patch release 5.5.4p2 fixed the issue for me.

    For 5.6 users, the patch release 5.6.2p1 fixed the issue for me.

    The release notes of both these patches include this bug fix - (907581) - UI: Fixed memory leak in UI:: DepthSortLayer() - which I believe is the offending issue.

    Hope that helps someone if they are finding a ton of memory leaks related to UI:: PrepareBatches.
     
    Havokki and Peter77 like this.
  9. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,533
    I've come back to seeing Unity chewing up ram on multiple occasions before looking into it what was going on myself (seeing the Mesh memory constantly growing when UGUI canvases are on, then found this thread already reported it.) Tested 2017.2.b6 I'll probably update to the newer beta this week...


    Hopefully its fixed in editor as I'm finding I can't leave things running for too long before my ram is gone damnit.
     
  10. grizzly

    grizzly

    Joined:
    Dec 5, 2012
    Posts:
    357
    Reading through the many 2017.x beta and patch release notes I'm yet to spot anything related to this bug, sadly.

    The issue has been flagged as "fixed" on Issue Tracker for sometime now, yet it clearly hasn't and re-submissions are being rejected due to the existence of the current submission - which leaves me wondering whether or not the problem has fallen through a crack somewhere along the lines, Unity? :)

    Another thread discussing the same issue (which could be merged with this one, btw);

    https://forum.unity3d.com/threads/possible-memory-leak.486577
     
  11. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    2017.2.0b8 - not fixed yet, the editor still leaks.
     
  12. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,533
    oh I'll skip that one then

    some more noise in this thread will be a good thing then :D
     
  13. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    I submitted the issue a while ago and it was closed as a duplicate. After 2017.1.0p2, where the issue was supposed to be fixed but wasn't, I reopened the case and it was closed as a duplicate of another one (925340) witch I haven't found on the tracker. So, I believe, they know about it.

    https://fogbugz.unity3d.com/default.asp?922770_dafbm4vl1r7nkdq8
     
    grizzly likes this.
  14. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    Just checked, 2017.2.0b9 can be skipped too.
     
    Peter77 likes this.
  15. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,618
    I'm really surprised how long it takes to fix such critical crash bug. The only plausible reason can be, that there are even worse issues than this one.
     
  16. LocDogg

    LocDogg

    Joined:
    Jun 1, 2014
    Posts:
    5
    This issue forced me to revert from 2017.2.0b8 to a previous version.

    Thanks to Peter for the excellent bug report, and to Alex for sharing his 2017.2.0b9 results (saved me some time there) and for following up with Unity QA.
     
    Last edited: Aug 30, 2017
  17. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,533
    2017.2.0b10 is it fixed... anyone checked?
     
  18. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,533
    to answer my own question... I just tested b10.. and ugui stuff still leaking in the mesh memory.
     
    LocDogg and Peter77 like this.
  19. CarlosRincon

    CarlosRincon

    Unity Technologies

    Joined:
    Jan 28, 2016
    Posts:
    127
    Just hearing that we have a fix - aiming to have it in the next but one build.
     
    Player7, grizzly and andreyul like this.
  20. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,533
    "aiming to have it in the next but one build."

    the next build ? I hope so this bug is annoying to workaround especially as I'm using ugui and multiple canvases, memory chewed up quickly if left too long.
     
  21. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    Yes working on getting it to all the versions where its present (2017.1 and 2017.2). Along side the memory leak there was a performance bottle neck that wasn't caught during reviews that has also been fixed.
     
    Carpe-Denius, Player7 and grizzly like this.
  22. grizzly

    grizzly

    Joined:
    Dec 5, 2012
    Posts:
    357
    Good work. This couldn't come soon enough. Bonus points for the performance boost!
     
  23. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,533
    Is the fix in 2017.2.0 Beta 11?
     
  24. Pelican_7

    Pelican_7

    Joined:
    Nov 25, 2014
    Posts:
    190
    Great, thanks for the heads up. Looking forward to upgrading to Unity 2017 once this is patched :)
     
  25. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    As just a update the fix has now landed all over so should be in 2017.1.1p3, 2017.2.0f1, any beyond. As there was many bugs related to it the RN's may not contain the exact bug number you'd expect.
     
    LocDogg and Pelican_7 like this.
  26. GrassWhooper

    GrassWhooper

    Joined:
    Mar 25, 2016
    Posts:
    109
    so, after spending, an entire day, overly optimizing one script, that was recently created(it basically, just keeps adding and removing strings from a ui Text Element after leaving it running for like 2 minutes, this leak happens and over 2 GB of ram is spent, thinking it was an issue of mine as i was losing hope finally i have come across this topic :)

    i can affirm too, i did suffer from this issue, and switching my project to 2017.2.0 Beta 11 did not work for me, whereas switching to 5.6.2p1 did work as was recommended in this topic.

    big thanks for informing us, it is getting dealt with in the future patch
    i seriously, can't wait for 2017.2.0f1, seriously, memory leaks, are just..... brutal.
    hopefully, it won't be far from now, because working, on an old version, is just, not really fun (i want my donuts particle system :D )
     
    Last edited: Sep 16, 2017
    Pelican_7 and Bralgs like this.
  27. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    The scheduled release date for 2017.2 is this month.
     
  28. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,533
    Where is 2017.2.0f1?!, I'm getting impatient and just want this fix out already:)
     
  29. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,533
    Ok 2017.2.0f1, is out. and this appears to be fixed, but is it?.. mesh memory doesn't grow like it used to.

    I started the unity project, around ~700mb memory before playing it in editor...with it playing it grows to like ~1gb before I stopped testing.. ok seemed alright now.. well after playing again and this time leaving the game running in the background for 20mins...Unity was at ~3.2gb memory, it seems something is still wrong, it doesn't release the memory after stopping build play, and now the memory profiler doesn't show where its going either. Obviously with the bug being in beta releases I've used for a few weeks now I can't be sure if its my own project leaking memory, I don't think it is.. and this bug has just moved somewhere else. Someone else want to test it and confirm.

     
  30. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    @Player7 if you have your project that i can look at i can see but from testing multiple projects that we have it appears fixed in all cases. That being said the profiler window will still grow the memory a little larger then before in Editor as its now storing meshes to facilitate the rerendering of the UI via the preview. but even that will release the memory once the frame goes out of scope so cap out.
     
  31. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,533
    Yeah I'm aware of that, but this issue is something else, and I think its still related to this same bug.

    I noticed that disabling the canvases in editor play mode, will start reducing the memory that this related bug I'm having with ugui seems to leak gc alloc doesn't seem to clear up.. Ie leave the project playing for 10mins, with all canvases on.. usually goes up at around 5mb/s, say I let it get to around 3gb memory for unity.exe .. then disable canvases while still in play mode, the memory it chewed with canvases on, will slowly start getting cleared up bringing memory allocation for unity.exe back down to around ~1gb or whatever it was at before pressing play... however if I stop play in editor, while its chewed up 2gb+ of memory.. that allocated memory will never be released until closing unity.exe

    Luckily compiled build releases don't exhibit this ram chewing problem, I've checked it with 2017.2.0f1 and Unity2017.1.1p2 both same problem in editor.. I should stop uninstalling the older releases but I didn't have this sort of issue other earlier releases like 5.6

    I'll test again with Unity2017.3 and if its still a problem will look at reducing and cleaning up the project and send it... until then someone tell @Alex-Lian to find out what happened to my tshirt prize for bug testing 2017.1.

    ..Got that email over a month ago now