"moses" <[EMAIL PROTECTED]> writes:

> Hi all
> 
> The man page doesn't *really* say what it's .Does anyone know what is the exact
> meaning of this field - it's hard to belive that rss is the the number if current
> memory resident in 1024 bytes. I run several examples that show it
> the man page for rss
> 
> --
>      rss     the real memory (resident set) size of the process (in 1024 byte
>              units).

OK, here is *really* what it is ;-)

RSS (resident set size) is the amount of memory mapped in RAM, per
process. There may be unmapped pages, but that is often the first
stage of swapping the page away or discarding it altogether, so this
is not as bad as it sounds.

Neither SIZE nor RSS fields count the page tables or the task_struct
of the process: those occupy at least 12K of memory that is always 
resident. SIZE is the virtual size of the process (code+data+stack).

If you are really interested, go to your resident (pun intended)
kernel source tree. The header include/linux/sched.h defines
task_struct and mm_struct that contain the relevant per-process
info. Look at struct task-struct, it contains

struct mm_struct *mm;

and that, in turn, contains

unsigned long rss, total_vm, locked_vm;

Now look at the /proc interface to the per-process memory usage:
/proc/<pid>/status. Here is my bash:

$ ps
  PID TTY          TIME CMD
 2678 pts/3    00:00:00 bash
 2689 pts/3    00:00:00 ps
$ egrep "^Vm" /proc/2678/status
VmSize:     2580 kB
VmLck:         0 kB
VmRSS:      1400 kB
VmData:      276 kB
VmStk:        24 kB
VmExe:       508 kB
VmLib:      1444 kB

This is more detailed than ps or top. VmData is the heap. VmStk is the
stack. VmExe is the statically linked stuff. VmLib is shared
libraries.

All this comes from a function called task_mem() from fs/proc/array.c.
Vm{Size,Lck,RSS} come directly from task_struct->mm as explained
above. Vm{Data,Stk,Exe,Lib} are obtained by traversing the process
vmas that have all the details as flags.

Hope it helps,

-- 
Oleg Goldshmidt | [EMAIL PROTECTED]

================================================================To unsubscribe, send 
mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to