Doing a deep dive into profiling memory I found aaaaaall the online posts on best practices, methods, opinions and all that fun stuff. But in doing my own experiment I am running into something that confounds me.
So I have a test app where I start with an empty scene and then load assets in using Resources.Load.
In this app I am both hooked up to the Profiler, but I also write to an on-screen text element with Profiler.usedHeapSizeLong.
So in essence I am looking at the Memory Profiler window’s “Used Total” and in code I’m looking at Profiler.usedHeapSizeLong
In Editor those don’t match up at all, but they at least increase at about the same rate when I load new assets into the level.
My problem is that on device, while the Profiler window increases when I load in new assets, the code Profiler.usedHeapSizeLong stays about the same. It’s also wildly off from where it should be.
This is on both an OSX and an Android build.
So is usedHeapSizeLong just not accurate on builds? Or am I looking at it wrong? I admit that I am reaching the limits of my knowledge on memory profiling.
For a bit of background I’m trying to understand something that I have read numerous posts on and yet can’t seem to find any definitive answers to, at least not with any data backing them up. Just people saying “well of course it’s this” followed by “no, it’s obviously that”.
That question is, if I have PrefabA that references PrefabB which has MaterialY which uses MaterialZ which references TextureZ, when I have PrefabA in my scene, is TextureZ loaded into memory?
I did another test that was basically that ^ and the profiler tells me that yes, that texture is loaded into memory. But then I’m told by someone else that “no, that’s just a reference to TextureZ”. But the profiler says that texture’s memory size is in the “Used Total”. But looking at GC.GetTotalMemory() or Profiler.usedHeapSizeLong shows different numbers…
I DON’T KNOW WHAT TO BELIEVE! Help me believe please?