Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug Tons of Invalid Managed Objects in Snapshot

Discussion in 'Profiler Previews' started by Nullrigin, Aug 3, 2023.

  1. Nullrigin


    Nov 3, 2020
    Hey there.

    I'm currently investigating some memory issues in our game and have encountered this issue. Unfortunately, I have not found a thread/forum post related to this topic.

    Did anyone ever encounter this issue and found a cause for it?

    Additionally, (caused by this issue?), a lot of assets are not unloaded even though Resources.UnloadUnusedAssets is used (with Addressables 1.21.14 and Unity 2021.3.9f1). Some help hints also explicitly say to use UnloadUnusedAssets but this does not change anything.

    I took the snapshot with version 1.1.0-exp.1 of the Memory Profiler attached to the dev build of the Unity 2021.3.9f1 version. (Memory Profiler used in Unity 2023.1.6f1)


    Any help/direction would be much appreciated
  2. MartinTilo


    Unity Technologies

    Aug 16, 2017
    Could you please try to open that snapshot with version 1.1.0-pre.1 and see if the message about this bug persists?
    There is a chance that the upcoming 1.1.0-pre.2 release might fix it but I can't be sure without investigating it.

    There is also a good chance that there is a bug in 2021.3.9f1 that leads to faulty reporting. There was a bug tracked here that is now fixed in 2021.3.16f1, so you would need to upgrade to see if that fixes the issue in newer snapshots.

    If neither 1.1.0-pre.1 nor a newer 2021.3.x release fixes the UI issue, could you please file a bug report and post just the issue number (no link needed) to this thread? Ideally that would include the project. If that is not possible or if the bug reporter issue struggles to upload the project, a snapshot would be a good start. Then I can use the issue ID to grab hold of the snapshot and double check if 1.1.0-pre.2 fixes it, if it is something that's going wrong on the package side, or if we'd need a repro project. With that I could then inform our QA that they should send you a link to where you can upload the project.

    The issue mentioned in the Profiler UI would not cause issues with unloading, just with investigating why it might still be held in memory via managed reference chains. If there are any available updates to the Addressables package, particularly after you updated 2021.3.x, try those.

    Also for that second screenshot, while the issue with resolving the managed object means we can't check if managed references are keeping it in memory, it is also referenced by one native object. You could investigate what that is and maybe draw some conclusions from that.

    Also, you'll probably want to search your project for creations of AnimatorOverrideController and ensure that you set their name property to make it easier to debug them, both if they should eventually leak, but also to see if they might currently hold on to this AnimatorController in some way (like a static reference to the override controller?). If it is still referenced from a root (as opposed to a circular self reference), then Resources.UnloadUnusedAssets can't get rid of it.