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.
  2. The 2023.1 beta is now available for testing. To find out what's new, have a look at our 2023.1 feature highlights.
    Dismiss Notice

Question Other Native Memory

Discussion in 'Profiler Previews' started by Claytonious, Sep 13, 2022.

  1. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    845
    While trying to reduce memory usage, I invariably run into the situation pictured below: the vast majority of memory is "Other Native Memory" and looking at the native allocations gives little to no actionable information:

    upload_2022-9-13_11-3-58.png

    How does one get more detail about the root causes of this native memory so that we can reduce it? Are there build settings we can use that will expose more?

    @MartinTilo , you are our only hope! ;-)
     
    alexeyzakharov likes this.
  2. alexeyzakharov

    alexeyzakharov

    Unity Technologies

    Joined:
    Jul 2, 2014
    Posts:
    473
    @Claytonious did you have a change to try the latest memory profiler version? We've added All of Memory view which tries to explain the native memory usage - https://docs.unity3d.com/Packages/com.unity.memoryprofiler@1.0/manual/all-memory-tab.html

    Actionability of the native allocations is a huge topic that needs more exploration and work from our side. While some allocations may be actioned from c# code or asset configuration, unfortunately most of those can be acted only when you have a source code.

    In the screenshot you've provided:
    • UnsafeUtility is what was allocated in C# UnsafeUtility.Malloc calls - can be acted potentially, the information you might need for that is a callstack though :)
    • BaseObjectManager is a native hashtable that tracks all live UnityEngine Object instances - why is it 96MB is a good question.
    • No Root is an allocation which is not associated with any system and is a memory tracking bug we would like to fix.
    • "Objects" allocations are internal Unity Objects which were created to support some system - may be a bug or a system overhead (e.g. default texture/mesh)

    There are no build settings, sorry. The source of native allocations atm may only be tracked if you have a source code license and can build Editor or Player from a source code.
     
  3. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    845
    Thanks for the added information!

    I do have a source code license. Who would I contact in order to find out more about how to use that to track these? Do I just build the editor and player modules with jam, keep the source code around, build from that Unity editor, and then run on the same box?
     
  4. alexeyzakharov

    alexeyzakharov

    Unity Technologies

    Joined:
    Jul 2, 2014
    Posts:
    473
    I believe you would need to reach out to your support contact DRM/PRM.

    You would need to rebuild editor with a specific define set.