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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

How to check free / used memory?

Discussion in 'Scripting' started by betonos, Jul 27, 2012.

  1. betonos

    betonos

    Joined:
    Apr 2, 2012
    Posts:
    12
    I want to check the memory used by Unity process or free memory available, because I've run into Unity's dead end with memory management so I need to know when I run low on memory from within the editor (not player!).

    Any idea how to do that?

    I've tried System.Diagnostics.Process.GetCurrentProcess and I get System.InvalidOperationException: Process has exited, so the requested information is not available.
     
  2. znoey

    znoey

    Joined:
    Oct 27, 2011
    Posts:
    174
    this is a request for more details.

    Honostly i can't imagine you needing to see free / used memory unless one of these two things are occuring:
    A.) Your doing mobile
    B.) Your doing something really wrong.

    In Pro, you can see a profiler which shows memory usage on some things, but i find its inaccurate a lot.
    On iOS you can build and see how memory is allocated with XCode's tools.
    Mysteriously, i've not had a lot of issues with memory on android.

    There's so many reasons why you could be hitting a wall on memory that i just can't go on without knowing anything else and a great many of these little problems come from misuse of textures / materials, audio, and meshes.
     
  3. betonos

    betonos

    Joined:
    Apr 2, 2012
    Posts:
    12
  4. fschneider

    fschneider

    Joined:
    May 26, 2014
    Posts:
    42
    @znoey , what about scenario A? :)
     
  5. image28

    image28

    Joined:
    Jul 17, 2013
    Posts:
    457
    The profiler has memory usage. Free/Used, Unless I'm misunderstanding and you mean the memory usage of Unity itself.