Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Other Native Memory

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

  1. Claytonious

    Claytonious

    Joined:
    Feb 16, 2009
    Posts:
    900
    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

    Joined:
    Jul 2, 2014
    Posts:
    507
    @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:
    900
    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

    Joined:
    Jul 2, 2014
    Posts:
    507
    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.