Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Understanding memory in the main profiler

Discussion in 'Editor & General Support' started by gecko, Oct 12, 2020.

  1. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,240
    Hi, I'm trying to understand memory and VRAM usage in our game, as we've gotten a couple reports of games crashes due to "out of memory". So examining a dev build in the memory profiler (the one that's part of the main profiler, not the new "Memory Profiler" -- sure would be nice if those had different names), the amount of memory taken by Unity (second item in Simple panel) is initially 3.5gb, but after running around some, it increases to 5.8gb -- however, the things itemized below on the Simple panel (Textures, Meshes, Materials, etc) have only increased by maybe 200mb, so I don't know where all that increase is coming from.

    Meanwhile, GfxDriver increases from 3.5gb to 4.5gb. We're using Vegetation Studio Pro, which uses VRAM to calculate grass placement, so that is sorta not-surprising. But how does that fit into the overall numbers? Is GfxDriver a subset of what's included in the "Unity" total (even though it doesn't account for all of the increase?), and if so, why -- when that should be in VRAM, not RAM....right? Or if it's not included, then are textures loaded into both RAM and VRAM?

    I'm really confused, would greatly appreciate any help in understanding this! I haven't found any useful explanation of this in the docs.
     
  2. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,431
    Hello,

    Please excuse the late answer but in case this is still an open question for you or others:

    "GfxDriver" memory is not included in "Unity", and Texture Memory can be in both or either VRAM or RAM, depending on the current usage, VRAM upload status or if the CPU needs to retain a copy for e.g. Read/Write access. Right now, the Memory Manager does not yet differentiate between them and this also means that Texture Memory Usage doesn't translate directly to "GfxDriver" or "Unity" but possible a bit of both. Adding that crucial differentiation is on our backlog though.

    For 2021.2 we've reworked the UI of the Memory Profiler Module (the way I refer to it to differentiate it from the Memory Profiler Package) to clarify how these numbers contribute towards memory usage and remove ambiguity about overlap between them:
    Unity_09x3QU3jQw.png

    As for what exactly "Unity" (or in this new UI "Other") is made up of: Essentially all other tracked memory that doesn't fit into the other buckets. So that's reserved space in bucket allocators (used for native object memory) and all the UnityEngine.Objects or Allocations made directly in our native memory systems without being tied to a specific object. To get more details on these, you'd need to take a snapshot with the Detailed view, or the Memory Profiler Package. The later also shows the reserved and allocated memory in the "Memory Map" view and allows you to diff between to snapshots, something that might help you figure out where that extra usage of memory is coming from.
     
    gecko likes this.