Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

man getrusage 2 says

ru_maxrss (since Linux 2.6.32)
              This is the maximum resident set size used (in kilobytes). For RUSAGE_CHILDREN, this is the resident set size of the largest
              child, not the maximum resident set size of the process tree.

So what does this number mean exactly?

share|improve this question
add comment

1 Answer 1

up vote 5 down vote accepted

A process's resident set size is the amount of memory that belongs to it and is currently present (resident) in RAM (real RAM, not swapped or otherwise not-resident).

For instance, if a process allocates a chunk of memory (say 100Mb) and uses it actively (reads/writes to it), its resident set size will be about 100Mb (plus overhead, the code segment, etc.).
If after the process then stops using (but doesn't release) that memory for a while, the OS could opt to swap chunks of that memory to swap, to make room for other processes (or cache). The resident set size would then decrease by the amount the kernel swapped out.
If the process wakes up and starts re-using that memory, the kernel would re-load the data from swap, and the resident set size would go up again.

The ru_maxrss field of struct rusage is the "high watermark" for the RSS. It indicates the peek RAM use for this process (when using RUSAGE_SELF).

You can limit a process's resident set size to avoid having a single application "eat up" all the RAM on your system and forcing other applications to swap (or fail entirely with out-of-memory conditions).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.