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
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
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.
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.
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.
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);
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.
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.
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.
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.