- Home /
Memory usage in Profiler much less than on actual device
Hey guys,
today I attached the memory profiler to my physical S7 edge and after 5 minutes I had an average memory usage of 62 MB. The Google pre-launch reports on the other hand show me usage between 100 and 300 MB. Does anyone know where this huge difference comes from?
Answer by MartinTilo · Nov 30, 2019 at 10:12 AM
I'm guessing you used the Memory Profiler Module? You might also want to check out the Memory Profiler package. There are some difference in what Unity's memory Manager tracks and what the OS sees as memory usage. We're trying to close that gap. 1. Unity allocated buffers that might not be fully filed with memory. Use the Used vs Allocated row in the Memory Profiler Module or look at the Memory Map of the package to get a better understanding of this. The OS may or may not see unused put allocated buffer space as used, since it might have mapped the memory but not committed the pages. 2. We're currently (unity 2019.3 package version 0.1.0-preview.9) missing some memory Allocated by the Mono/IL2CPP VM, notably codegen for generics. We're on it. Also note that you can see the VM memory that we do track already in the memory map. The amount of memory Allocated for generics in IL2CPP can be quite significant. 3. Native Plug-ins allocate without going through Unity's Memory Manager.
I'm guessing you might be facing a mixture of these.
Thank you for your detailed answer. I am using the $$anonymous$$emory Profiler package. After some days of testing it seems like the gap isn't even that big, because my app uses ~90$$anonymous$$B on low-end and ~200$$anonymous$$B on high-end devices. I think that's how Android manages memory. So the gap would only be about 20$$anonymous$$B, which is quite acceptable.