Search Unity

Real Memory goes up, but not down

Discussion in 'Editor & General Support' started by devknob, Jul 23, 2009.

  1. devknob

    devknob

    Joined:
    Apr 2, 2009
    Posts:
    66
    In testing for memory using the xcode instruments
    I created 100 instances of my class that each created a huge string to see obvious increase in memory usage, and then destroyed all the objects. The "Real Memory" doesnt go down when I destroy everything, and it doesnt go up more when I repeat the process.

    Can someone explain this to me? This makes it tough to see actual/real time memory usage. What exactly is Real Memory?
     
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Thats basic managed environment behavior


    The GC will not release the memory unless its not used for a long time and as you freed the instances, it has a large pool to create new objects from so it does not need to allocate further memory from the OS.

    Thats what makes GC systems as performant as they are although they are managed etc and its also what makes "from the outside watching" on the ongoing things that useless, as you don't see what the GC does if you don't look from the inside.
     
  3. devknob

    devknob

    Joined:
    Apr 2, 2009
    Posts:
    66
    Thank you for your response Dreamora!

    What is the best way to view the memory currently used if Real Memory/outside tools are useless? How I do I look from the inside? =)
     
  4. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Up to a given point with the System.GC class.
    But I'm not sure whats all implemented in Mono 1.2.5 for it.

    Its commonly not even needed. Its not C++ where you leak memory all day long if you don't run after each pointer like an insane :)
    If the pool is full, it will allocate new memory for the pool, if it isn't full it will allocate the objects from the pooled memory.