I’m noticing that all around, there’s inconsistencies on how much memory is being used in the memory profiler. I’m on version 5.0, the latest version.
I’ll notice that in the summary (the first dropdown at the top), it’ll say that 12GB of memory is being used/tracked with 2GB of memory untracked (this is alarming in itself but less-so when I see other results).
I then go to the tree-grid below the summary dropdown and all of it adds up to less than 7GB of memory?
I then go to the task manager and notice that my game is using 8GB of memory.
Why are there such discrepancies in the memory profiler?
The Tree Maps and default Table underneath it is filtered to show all memory used by Objects, native or managed. There are also non-object associated native allocations and preallocated pools and buffers. The Fragmentation Page, the All Native Allocations Table and the All Memory Regions Tables give a more complete picture of memory usage, albeit less concrete in terms of items one usually encounters within the Editor.
To give you a better explanation of what might be going on with your discrepancy between the total used in the tool vs Task manager it’d be good to know if your, as it sounds, using windows, which Unity version you are using and what that memory usage overview looks like for that snapshot.
Generally speaking though, is this something we are working on closing the gap on, including the Untracked part. What could constitute the Untracked amount is displayed in the Memory Profiler windo when you select that bar or the row for it.
First of all, I do thank you for putting thorough descriptions in the memory window, that has helped out already. For instance, I didn’t know that having read/write enabled will double it’s memory ingame.
Second of all, thanks to alex’s reply, I think at this point, I’m just going to have to wait it out since it sounds like unity’s memory manager keeps track of all the objects currently referenced or having references in the scene, but anything that isn’t related to an object will be in the ‘unknown’ category.
But to give more insight into my specific problem, here’s a few screenshots from the memory profiler on my discrepancies.
Task Manager-4.2GB of memory:
Memory Profiler-7GB of memory (with 5.71 being tracked):
Grid-5.2GB of memory is the sum of all these grids:
So you can kind of see where I’m getting confused.
Oh you also wanted the specs so this is Unity 2020.3.25f1 on a Windows 10 GTX 1050 laptop
No. Everything the snapshot has information on is in the Tracked category. Wether that’s Object associated or floating allocations or preallocated buffers. But the tree map only shows objects. You’ll have to look that the Objects and Allocations page and choose the All Native Allocations Table or the Fragmention page. There is information for all of the 5.44GB of Tracked memory in the snapshot.
Unknown contains native plugin memory, IL2CPP Virtual Machine memory, etc as listed in the UI when you select it.
The other bar would be interesting to see in this context, the one with the Graphics & Graphics Driver category. E.g. I’m not certain how much that category is measured in the Task Manager, as that might not list dedicated VRAM usage? If you switch from Task Manager to Resource Monitor, that may become clearer too.
Also Executable and DLL may not fully count as working set. A can part of it be shared with other apps (Because that’s what a dynamically linked library allows for) and it is likely not modified after loading from disk.
As for the difference, memory usage can fluctuate, and results might differ depending on the moment a sample is taken. We take samples around the frame end. Process Explorer probably takes them with a specific fixed time interval. Something inside Unity might allocate/release memory in between these intervals.