Search Unity

  1. We're looking for feedback on Unity Starter Kits! Let us know what you’d like.
    Dismiss Notice
  2. Unity 2017.2 beta is now available for download.
    Dismiss Notice
  3. Unity 2017.1 is now released.
    Dismiss Notice
  4. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  5. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  6. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    Dismiss Notice

Total memory usage

Discussion in 'Editor & General Support' started by LumpN, Aug 3, 2015.

  1. LumpN

    LumpN

    Joined:
    Jul 13, 2014
    Posts:
    8
    Is there any way to query the total RAM usage of the standalone player? All Unity functions seem to report only the sandboxed mono part of memory usage. And System.Diagnostics.Process.workingSet64 returns zero inside Unity.
     
    Velo222 likes this.
  2. Velo222

    Velo222

    Joined:
    Apr 29, 2012
    Posts:
    1,138
    Having the same problem. Would love to know how to do this. No one seems to know for some reason. And it seems like a really common thing you would want to know -- how much total RAM is my application using on the system.
     
  3. Bryangs

    Bryangs

    Joined:
    Feb 26, 2014
    Posts:
    49
    Are you talking about how much RAM is your game using? There are hundreds of different ways of measuring that.

    You can use Unity's profiler, you can use RivaTuner, etc, etc, etc. Even the task manager lol
     
  4. Velo222

    Velo222

    Joined:
    Apr 29, 2012
    Posts:
    1,138
    Yes, but the issue is getting a real "hard number" of total memory being used, from code, while not using the profiler.

    You can't use the profiler functions during a real game build, as the profiler is not attached. And my use-case is for getting the total RAM my game is using during a standard game build in order to use it as a condition in my code (i.e. during the game while the player is playing). That is, if during the game the memory goes above 1.4 GB, then do "xxxxx" (in code).

    So it's not as easy as you are suggesting. I have yet to see a simple Unity function that returns the total amount of memory your game is using during runtime -- during a play session apart from the Editor/profiler.
     
    Last edited: Apr 18, 2017
  5. Bryangs

    Bryangs

    Joined:
    Feb 26, 2014
    Posts:
    49
    I don't understand what are you talking about.

    You CAN use the profiler while playing a build, i do it all the time.
    As i said, every single one of my examples clearly specifies the exact ammount of RAM your game is using.

    Now about coding, that's kinda... uncommon. I never tried to do something like this, but i am pretty sure this wouldn't be a good thing to do, as you would have to somehow gain access to the user's PC, and hack into the system to get the ammount of RAM X application is using separately from every single other task. Not to mention the difficulty of doing this, as memory types and specifications can vary. Also, if the user has an antivirus, it will surely detect this as some kind of malicious action and crash/block your game, and it can ALSO cause performance issues.