Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. The 2023.1 beta is now available for testing. To find out what's new, have a look at our 2023.1 feature highlights.
    Dismiss Notice

Question How to know the total amount of memory that a capture is taking?

Discussion in 'Profiler Previews' started by francismoy, May 20, 2020.

  1. francismoy

    francismoy

    Joined:
    Jul 5, 2017
    Posts:
    41
    I have taken a capture of my game from my smartphone with the memory profiler and I would like to know the total amount of bytes that this capture is taking on the device.

    There are lots of numbers like total allocs, all managed/native objects, etc, but I don't know how to calculate the total amount of memory (in bytes, MBs, etc) or if this number is accessible somewhere. Is it possible?

    Sorry in advance if this is a silly or straightforward question.
     
  2. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    1,911
    Hi,
    Totally not a silly question but a shortcoming of the memory Profiler package as it currently is, and also partially a problem with the current memory snapshot capture backend. The backend issue is, that we don't actually capture what the entire memory usage of the app is. Some platforms attribute memory usage to different apps different than others (and use that info to decides what gets kicked out of memory). Also, Unity doesn't necessarily know about all memory Allocated by the App, in part due to native plugin memory not being tracked.

    The UI should sum up everything it does knows about though and we'll add that.

    The closest you can currently get to that is to sum up the sizes in Table > Alloc >ByMemRegion or ByRoot. That will get you the closest to what the OS sees but Unity allocates memory in buffers that might be empty so it's not a great way to see if you optimizes the memory usage because you might be using less Memory in these buffers but their size will remain that big until you reduced it even further.

    We're working towards better memory reporting from the OS, getting you an overview number in terms of Used vs Reserved (similar to the Memory Profiler Module in the ProfilerWindow) and summing these things up so you don't have to. But we're currently addressing even more fundamental issues of the code base to make sure we can make these and similar UI changes efficiently. That means we're currently a bit slow at improving the UX and UI but should be able to really double down on them soon and with a good cadence.
     
  3. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    1,911
    So for now, the best workaround is to get an overview from the ProfilerWindow and do the deep dive in the Memory Profiler package.
     
  4. francismoy

    francismoy

    Joined:
    Jul 5, 2017
    Posts:
    41
    Great! Thanks for the detailed answer. It's understandable. I find this tool really useful and I'm glad that you're working on it to improve it.
     
    MartinTilo likes this.
  5. MrGuardianX

    MrGuardianX

    Joined:
    Sep 29, 2014
    Posts:
    54
    Thank you for the detailed answer. Would be really cool to see Total parameters in the Memory Profiler package. It is a good instrument for looking up specific problems with specific objects, but not really helping to find out how much memory our game is using on the specific device.
     
    MartinTilo likes this.