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.

Official Memory Profiler 1.1.0-exp.1 Released

Discussion in 'Profiler Previews' started by MartinTilo, Mar 22, 2023.

  1. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    1,968
    Hello y'all :)

    We have released version 1.1.0-exp.1 of the Memory Profiler package. This version brings new functionality under the themes of improving Resident vs Allocated Memory analysis and improving Managed Memory analysis. It also contains a good set of fixes for bugs and usability issues you've raised since the 1.0.0 release. See below for details of what’s new.

    What we’ll cover
    • Resident Memory Information
    • Managed Object Search Improvements
    • Improved Comparison Mode
    • Render Texture Details
    What’s New
    Resident Memory Information
    Problem
    If you only look at Allocated Memory, you might be misled by which allocation consumes your physical memory and optimize something that isn’t a problem. Consequently, you waste time and do not see any difference in your application performance and stability.

    What is Resident Memory?
    Resident Memory is the amount of physical memory used. This amount is usually lower than the Allocated (committed) amount of your application, as some allocated space may yet be untouched ("empty"), or hasn’t been accessed for some time and moved by OS to a secondary storage, for example page swap file or compressed memory. The amount of Resident Memory is therefore the primary number used by the OS when it determines whether or not to kill your app. I.e. if the Resident Memory usage of your app exceeds the physically available memory, or the amount of memory determined by the OS to be safe to be used by just one application, it will deny further allocations (OutOfMemory exception) or directly terminate your app.

    In this version of the Memory Profiler, our goal is to guide you through the differences in Resident Memory and Allocated Memory so that you can easily see where the potential problem areas are.

    Changes We’ve Made in 1.1.0-exp.1
    We have added the ability to see how much memory each native object, C# allocation and other reported entries contribute to the Resident Memory amount. This is available for all snapshots taken from Unity versions 2023.1+ and on Windows, Linux, Android, MacOS and iOS.

    The Summary View's bars show the Resident Memory bars on hover and all tables now have different view modes, which allows you to switch between Allocated/Resident/Allocated and Resident views via a drop-down next to the search field above the table. We’ve also updated the description shown when selecting the Total Resident On Device bar or legend row on the Summary page with more descriptive and hopefully more helpful explanations of Allocated and Resident memory.

    We've also published a blog post with more info on this topic.



    Managed Object Search Improvements
    Problem
    We've heard your feedback that it was not possible to find an object of a specific type in 1.0. And that managed objects had a generic “<No Name>” name.

    How We Solved It
    In 1.1.0-exp.1 we expanded the search functionality to include any value used in the Description column of a table. You can now search by type, any other group names (like "Graphics" in the All Of Memory table), and by the managed address value or instance ID. Managed addresses are now displayed in the All Of Memory table for managed allocations.

    We added the post-fix "(Leaked Managed Shell)" to managed UnityEngine.Objects with a Destroy()ed native object, so you can now easily search for all leaked shells (more info on those has been added to the documentation) in the All Of Memory view.

    Scripting Types You’re Familiar With: Managed Types Inheriting From MonoBehaviour & ScriptableObject
    In the Unity Objects table, all of your scripting types that inherit from MonoBehaviour or ScriptableObject are now subdivided by their managed types. This not only allows you to search and filter by those type names and namespaces, but also helps to analyze which of these types have the biggest impact on your native memory usage; which is mostly a factor of their total count and their serialized data. This also makes the Potential Duplicates analysis more precise.


    (As shown above, searching by the managed type can filter by namespace as well as type name. The single entries for Unity Object types, like “AppSettings” and “Hakeem”, still get their name from their native object, and in case of MonoBehaviors the GameObject they are attached to. Purely managed Objects are listed with their address value. You can also see the Unity Objects table grouping the MonoBehaviour objects by their managed type)

    (A quick look at all Leaked Shell Objects. The selected one being held by a static reference in it’s own class in the manner of a typical Singleton pattern.)

    Improved Comparison Mode
    Problem
    When comparing snapshots, it was hard to understand which objects were the same between the captures. In Base and Compare tables objects were completely indistinguishable from each other without selecting them one by one and checking their details.

    How We Solved It
    In this version, we've changed this so that managed objects in All of Memory view are named via their address in memory.

    Additionally, when comparing snapshots from the same session, we now list native objects (or Managed UnityEngine.Objects that have a native object) individually by their instance ID in both Unity Objects and All of Memory views. This is also reflected in the Base and Compare tables, making it easier to see which object is which in each snapshot in a similar manner as the address values for managed objects.


    (Above you can see an example of how the Instance ID can help you see what items in the Base and Compared tables stayed the same and which ones changed. In 1.0 all items in the bottom table would be named “DepthOfField”)

    Render Texture Details
    Memory Profiler now also displays the MetaData for RenderTextures - format, size, etc. similarly to the Texture object types. In conjunction with the 2023.1 version of Unity we also display additional information such as whether a resolve surface is used for the color and/or depth surfaces.



    We're also continuing to improve the detailed coverage of all native and graphics related memory such as Audio system and Graphics buffers.

    Bug Fixes and Improvements
    We've fixed some bugs, UX issues and inaccuracies around the Select and Search in Editor/Scene/Project buttons. We've also revisited a bunch of descriptions, names and tooltips.

    For the full details of all the changes, please see the Change Log.

    What's Next
    We are focusing on stabilization of Memory Profiler and releasing the final 1.1.0 version in the coming months.

    How To Install
    Go to
    <YourProjectPath>/Packages/manifest.json
    and add or modify the entry for the memory profiler to:
    Code (CSharp):
    1.     "com.unity.memoryprofiler": "1.1.0-exp.1",
    We Would Like To Hear From You
    We've already collected some feedback from some of you along the development of 1.1.0-exp.1 to refine some of the more complex new parts while we worked on it, but now we want to open it up to all of you to hear your feedback, while we refine it for the full 1.1.x release.

    For example, we know that there are probably more usability gains to be had by a more advanced search feature but we'd love to hear what you think about it, what you're missing and what workflows you feel are underserved by it at this stage.

    We’d be happy to hear your feedback, which you can provide to us directly via our public roadmap. If there is something you are unclear on and/or want to discuss, you can of course also do that via the forums, as a reply to this thread or in the Profiler Previews section of the forum.

    Let’s build the tool together.

    Thank you.
     
    Last edited: Mar 29, 2023
    Hik-AV, Wattosan, Agnes_C and 4 others like this.
  2. khan-amil

    khan-amil

    Joined:
    Mar 29, 2012
    Posts:
    205
    Hi, we're using this tool, and having only used before the old 0.6/7 version of the tool it's great to see the improvements.
    However, we're seeing a huge "Empty fragmented heap space" region in our app while profiling, and I do miss the old fragmentation tab.

    Looking back at your explanation as to why it was removed it doesn't make much sense to me. Yes it was hard to use and needed deep knowledge of the engine to use it really, but optimizing for consoles does require this a lot of the times, and now we just have one less tool to act or inspect the memory.

    Any chance we could have more details on these sections coming up in some way?
     
    alexeyzakharov and MartinTilo like this.
  3. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    1,968
    Hi @khan-amil,

    Thanks for the feedback! It's good to hear that the previous UI for this was helpful. We don't currently have any concrete plans to bring back that UI but I logged your feedback through our roadmap feedback submission form so we keep track of it and can prioritize accordingly.
     
    alexeyzakharov likes this.
  4. alexeyzakharov

    alexeyzakharov

    Unity Technologies

    Joined:
    Jul 2, 2014
    Posts:
    501
    Hi All!
    We've released bugfixes update to the 1.1.0 experimental release line.

    [1.1.0-exp.2] - 2023-04-20
    Added
    • Added metadata support for AudioClip and Shader objects.
    Fixed
    • Fixed Unity Objects view not showing graphics resources for snapshots made with Unity 2022.1 and older
    • Fixed leaks of native UnsafeUtility.Malloc(Persistent) allocations
    • Fixed snapshot renaming issues in situations when warning or error dialog is shown
    More Details
     
  5. vzlomvl

    vzlomvl

    Joined:
    Jun 25, 2016
    Posts:
    41
    Hello. The blogpost have infromation about additional information about Resident memory in Unity 2022.2+ snaphots upload_2023-5-5_16-1-27.png
    but this forum post have information about Unity 2023.1+ requrement. upload_2023-5-5_16-2-34.png
    Could you please clarify if I can use Unity 2022.2 to get additional Resident memory information with Memory Profiler 1.1?
     
    alexeyzakharov likes this.
  6. alexeyzakharov

    alexeyzakharov

    Unity Technologies

    Joined:
    Jul 2, 2014
    Posts:
    501
    Thanks for spotting the inconsistency in the blogpost! The forum post is correct.
    And to clarify - when you use Memory Profiler 1.1:
    • In Unity 2022.2 - you will be able to only see total resident memory usage in the Summary tab.
    • In 2023.1 - you will be able to see resident memory usage in all other tabs - Unity Objects, All of Memory - on supported platforms.
     
    vzlomvl and MartinTilo like this.