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.

It says

   p: SWAP  --  Swapped size (kb)
  The non-resident portion of a task's address space.

   q: RES  --  Resident size (kb)
  The non-swapped physical memory a task has used.

  RES = CODE + DATA.

Okay, what does "non-resident portion" mean?

Does SWAP mean that hard disk is used as additional memory?

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

Yes, swap is when the hard disk is used to hold memory once RAM is full; on Linux it's normally held in a separate swap partition, but can use files. Mac and Windows use files on the regular filesystem. Paging excess memory out to disk like that keeps the OS from having to kill processes to free up real RAM, which is why it is generally recommended to have a swap partition for your Linux installation. However, it's a great deal slower (several orders of magnitude) than real RAM, which is why it's only used as a last resort (and why so much time is put into figuring out which page [4kB chunk of memory] to send to swap).

share|improve this answer
    
What does non resident mean then? –  Jim Thio Feb 16 '13 at 16:13
    
@JimThio Same thing, non resident in memory. i.e in swap/disk –  mtm Feb 16 '13 at 16:20
    
@JimThio non-resident describes the memory while it is on the hard disk, i.e. not resident in physical RAM. –  Kevin Feb 16 '13 at 16:57
add comment

Besides your configured paging devices, swap also counts pages that come from files mapped in with mmap. These pages are only actually loaded into physical RAM when they are referred to by the program. These pages will be paged out to the original file rather than to the swap devices if they ever need to be paged out.

paxdiablo explains this here: http://stackoverflow.com/questions/1972765/mmap-problem-allocates-huge-amounts-of-memory

Or see the mmap man page.

share|improve this answer
    
I don't think that value is accounted as OS swap though (unless using mmap in a way that it needs swap, like MAP_PRIVATE). Although an mmaped file can be functionally swapped out of memory when the kernel needs to, this doesn't involve a write to normal swap as the backing file already exists elsewhere on your file system. In my mind, no writes to swap = no swap usage. –  mtm Feb 16 '13 at 19:53
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.