Search Unity

  1. We've closed the job boards. If you're looking for work, or looking to hire check out Unity Connect. You can see more information here.
    Dismiss Notice
  2. We're running great holiday deals on subscriptions, swag and Asset Store packages! Take a peek at this blog for more information!
    Dismiss Notice
  3. Check out our Unite Austin 2017 YouTube playlist to catch up on what you missed. More videos coming soon.
    Dismiss Notice
  4. Unity 2017.2 is now released.
    Dismiss Notice
  5. The Unity Gear Store is here to help you look great at your next meetup, user group or conference. With all new Unity apparel, stickers and more!
    Dismiss Notice
  6. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  7. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice
  8. Unity 2017.3 beta is now available for download.
    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,145
    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:
    50
    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,145
    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:
    50
    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.