Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is resident and dirty memory of iOS?

Can some one please tell me, what kind of memory is dirty/resident, and where do they come from? Does resident memory means the same with "wired memory" of Mac OS?

this is what I saw about Mac OS memory:

Wired : This refers to kernel code and such. Memory that should not ever be moved out of the RAM. Also know as resident memory.

Shared : Memory that is shared between two or more processes. Both processes would show this amount of memory so it can be a bit misleading as to how much memory is actually in use.

Real : This is the "real" memory usage for an application as reported by task_info() - a rough count of the number of physical pages that the current process has. (RSIZE)

Private : This is memory that a process is using solely on it's own that is used in Resident memory. (RPRVT)

Virtual : The total amount of address space in the process that's mapped to anything - whether that's an arbitrarily large space for variables or anything - it does not equate to actual VM use. (VSIZE)

Active : Memory currently labelled as active and is used RAM.

Inactive : "Inactive memory is no longer being used and has been cached to disk. It will remain in RAM until another application needs the space. Leaving this information in RAM is to your advantage if you (or a client of your computer) come back to it later." - Mac OS X Help

Free : The amount of RAM actually available without any data.

like image 255
CarmeloS Avatar asked Nov 18 '12 04:11

CarmeloS


1 Answers

It's almost a year and I figured it out.

clean memory

clean memory are memories that can be recreated, on iOS it is memory of:

  • system framework
  • binary executable of your app
  • memory mapped files

Also notice this situation: when your app link to a framework, the clean memory will increase by the size of the framework binary. But most of time, only part of binary is really loaded in physical memory.

dirty memory

All memory that is not clean memory is dirty memory, dirty memory can't be recreated by system.

When there is a memory pressure, system will unload some clean memory, when the memory is needed again, system will recreate them.

But for dirty memory, system can't unload them, and iOS has no swap mechanism, so dirty memory will always be kept in physical memory, till it reach a certain limit, then your App will be terminated and all memory for it is recycled by system.

virtual memory

virtual memory = clean memory + dirty memory.

That means virtual memory is all the memory your App want.

resident memory

resident memory = dirty memory + clean memory that loaded in physical memory

resident memory is the memory really loaded in your physical memory, it mean all the dirty memory and parts of your clean memory.

conclusion

At any time, this is always true:

virtual memory == (clean memory + dirty memory) > resident memory > dirty memory

If you are worrying about the physical memory your App is taking(which is the key reason your App is terminated due to low memory), you should mainly focus on resident memory.

like image 84
CarmeloS Avatar answered Sep 23 '22 05:09

CarmeloS