Search Unity

Unity 2021.2.0a18/a19 Memory Profiler Module UI changes

Discussion in 'Profiler Previews' started by MartinTilo, May 28, 2021.

  1. MartinTilo


    Unity Technologies

    Aug 16, 2017
    Welcome to the discussion thread for the UI changes to the Memory Profiler Module (i.e. not the package but the UI in the Profiler Window). You can use this thread to ask for help, share feedback, and have discussions about the Memory Profiler Module.

    The Memory Profiler module has a Simple and a Detailed view. The Detailed view is unaffected by this change as the Detailed view is in "Maintenance" Mode (*1) as we focus on the Memory Profiler Package. From the work of an upcoming overhaul and UI and Usability improvements for this package, we've now brought some of those back into the Memory Module.

    Specifically, the previous text version of displaying the high-level memory stats was a cause for confusion in the past, with uncertainties around the question of how these numbers relate to each other, whether there is any overlap or double counting going on, which "Total" number to trust in and how this relates to what the Task Manager or External Profilers report. Additionally, these numbers where not reflected in the Memory Profiler Package, making it harder to draw at a glance connections between what those two tools are showing.

    What changed?
    While you'll have to be a bit more patient on the package side of this change, as of 2021.2.0a19 the Memory Profiler Module changes have landed. It takes the previously shown counters in a clearer way with only minor changes:
    • "(Total) System Used Memory" -> The "Total" amount of the bar. This number is based on the best fitting number (*2) the specific platforms Operating System can give us, or the sum of all tracked memory where the OS doesn't (mostly just the case when looking at data of older Unity versions as all platforms should be covered)
    • "Unity" -> "Other"
      • There is no clear line as to where Engine internal resources end and User resources begin, so "Unity" was a bit misleading to begin with, which is why newer versions already didn't track it explicitly
      • This does not map to "Other" in the Details view, it's just the remainder of what Unity's Memory Management System is tracking minus all other categories.
      • To get more information on the makeup of this or the other categories, take a snapshot in the Detailed view or with the Memory Profiler package.
    • Total Committed Memory
      • This bar clarifies how much Memory Unity's Memory Manager is tracking (under high-level counters) and how much it just can't quantify but the OS told us we're using.
      • Some examples of untracked memory are: memory allocated through native plugins or some drivers, Mono or IL2CPP Type Metadata or for the executable code and DLLs. The Memory Profiler package might have some more information on some of these untracked amounts, but where it doesn’t, a native platform provider may be able to shed more light on the untracked amount of memory.
      • We are working towards closing that instrumentation gap down

    New UI:
    UtfIKuaYbt.gif Unity_ThXzHbKBRy.png Unity_xZ495FdneD.png Unity_SieB6Ea3JE.png
    Previous UI:

    Some other notes:
    Not all memory systems use pools or differentiate between used and reserved memory. Those that do, show two numbers, the used and the reserved amount of memory. If the used amount does not share the same Unit (B, MB, GB) as the reserved amount, it will be displayed, otherwise it is omitted.

    Texture and Mesh memory does not map 1-to-1 to Graphics & Graphics Driver memory as some of that memory might also fall into the “Other” category of the Total Memory Breakdown bar.

    The Normalized Toggle defines whether the bars should be fitted to the memory usage of just this frame, or if they should be shown in comparison to the maximally used memory within the shown frame range. This option is there to help you see how the total or the relative amounts change frame over frame.

    Please feel free to post any related feedback or questions in this thread.

    How to report bugs
    Please report bugs through Unity’s built-in bug reporter tool, located in “Help/Report a Bug…”. Once you have submitted a bug report through the bug reporter, please feel free to start a discussion about it in this thread.

    (*1) While fixes and improvements to the data reporting back end of the Memory Profiler also affect the data shown in the Details view, the UI side is in maintenance mode, as our focus lies on replacing all workflows it offers with the Memory Profiler Package (with a possible re-convergence in the same place UI wise down the line)
    (*2) There may be a slightly more accurate version available, e.g. on Android, but querying that might come at too steep a cost (e.g. >300ms on Android) to ask for it every frame but for most intents and purposes, this should be accurate enough.
    Last edited: May 28, 2021
    polemical, Ruchir, Xarbrough and 7 others like this.
  2. APSchmidt


    Aug 8, 2016
    2021.2.0a19? 0a18 hasn't been released yet.
  3. MartinTilo


    Unity Technologies

    Aug 16, 2017
    I guess, to be accurate, both. Some minor tweaks landed on a19 but the change comes with a18.
    And yes, this is the profiler preview's forum after all ;)

    No, joking aside, I'm not a time traveler but there is a bit of a delay between stuff landing and the versions going through the full release testing and publishing phase and I'm on vacation for the next 2 weeks so I kinda went ahead of the actual release with the post.
  4. mahdi_jeddi


    Jul 18, 2016
    This is pretty good. Way nicer and more informative than just showing some numbers. I assume the untracked memory size is smaller on Player compared to Editor. Hopefully it gets better in later versions. I think it would help to show some text there to describe what it is right in the UI.
    MartinTilo likes this.
  5. Miguel_Merayo_Scopely


    Jun 7, 2021
    Wow all this looks amazing.
    I discovered Memory Profiler Package a year ago and it super useful. I still need to learn a lot about it and memory in general, but this tools is helping a lot identifying problems, and learning about memory.
    I have some questions about this package, I don't know If I could use this forum for this.
    • Is there any way to get the total amount memory used?
      • For example on treemap would be nice to see the total managed/native
      • In table see the amount managed and native of the current view.
    • Is there any way to export table results? Something like export to csv and be able to do some external analysis
    • In our project we were thinking of identifying the memory per hierarchy, so we know what gameobjects and children are wasting more memory. I was thinking of having a tree map like view but ordered on hierarchy instead of ordering per type. This would be awesome, but it have only been able to measure types size, using UnsafeUtility.SizeOf. I don't know if there's any way to extend the package and try doing this.
    • Sometimes I feel like the numbers doesn't match exactly between this and standart memory profiler. And they are even more different with native xcode profiler. For example on textures using xcode gpu capture, is showing some "not used textures" that it looks like memoryprofiler is not couting.
    MartinTilo likes this.
  6. MartinTilo


    Unity Technologies

    Aug 16, 2017
    Aye, that is a good point. Thanks for raising this, I'll look into adding some of the info into tooltips.

    And yes, the goal is to keep chipping away at the Untracked block. One of my more recent discoveries was that Marshal.AllocHGlobal allows you to allocated memory in a way that is untracked by Unity's memory tracking systems.

    We are currently overhauling the Memory Profiler Package's UI and adding such totals to the views is one thing we are doing in there :)

    That is also something we want to add with each overhauled view as we go. CSV export might be based on only the current view or multiple files, as the format doesn't support multiple sheets / data sets which need different columns.

    Yes, we're looking at adding some more data to the backend in order to be able to fully reconstruct the scene hierarchy and show such a view.

    Profiler.GetRuntimeMemorySizeLong(UnityEngine.Object object) gives you the size of a Unity engine.Object in native.

    They are using the same backend, the memory profiler module just doesn't request/read the managed memory bits, so they should match. With this change here and one in the package that we still need to ship, we are aiming to align the top level breakdown to also line up. I'm not aware off any other difference so that sounds like a bug?

    Yes there are some platform specifics and some gaps that we need to close. There's also this thread going into how XCode attributes memory slightly different.
    Some of this might however be down to bugs or gaps that need fixing/closing.

    Thanks for the feedback and points to take another look at :)
    mahdi_jeddi likes this.
  7. Ruchir


    May 26, 2015
    There are a few problems with the interface right now:
    • No scrollbar present for cases where vertical height is not enough to show all of the data. upload_2021-7-11_20-18-53.png upload_2021-7-11_20-19-24.png
    • When I select a frame and then un-pause the game again, This is what I see after the frame I selected in out of the region being shown. upload_2021-7-11_20-20-48.png
    • The only way to bring back per frame data(without selecting a frame which I can if just select he memory profile just after opening the profiler) is to close and open the profiler again
  8. MartinTilo


    Unity Technologies

    Aug 16, 2017
    Hi @Ruchir
    Good point. The Memory Profiler package version 0.4.0 overrides the Profiler Window Memory module UI and I've already corrected that in there. I might bundle that as a fix with other changes to put it in the editor without needing the package but for now, this would be solved as soon as that package version will be shipped (subscribe here for updates).

    As to your other two points, that's the exact same behavior as for other profiler modules, like the CPU or GPU module. You can bring back live updates based on the current frame by toggling on the 'Current Frame' toggle in the toolbar, i.e. the
    button. I'll look at clarifying that message and the Current Frame UX as you're not the first one to be confused by that.
    Ruchir likes this.