Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How does one go about determining if a process is constantly swapping memory on Unix? I'm using the top utility but I don't quite understand the details of that report.

share|improve this question
    
Found a good article using vmstat: linuxjournal.com/article/8178 –  syker Mar 1 '12 at 22:54
    
What Unix ? By the way, a process doesn't swap memory. That's the kernel which does it, and more precisely, the kernel reacts to page faults by paginating memory from the swap area to the RAM, and move RAM pages to the swap area should free RAM is needed. –  jlliagre Mar 1 '12 at 23:11
add comment

1 Answer 1

I think the real question is, whether the system is constantly swapping memory.

An active process, on it's own, might not swap a lot, while the system swaps other processes and data out to make space for it.

vmstat is a great tool for analysing virtual memory statistic.

qdot@valentha ~ $ vmstat       
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
 3  0      0 5055564   1244 1651244    0    0   291   149  383  750  6  2 87  5
share|improve this answer
    
Based on the example output of vmstat you provided, could you perhaps walk me through what is happening on your system and what you typically look out for? –  syker Mar 1 '12 at 22:35
    
According to man vmstat, swpd refers to the amount of virtual memory being used. Is that also an indication of how much memory get "swapped" (swpd) by the system constantly? –  syker Mar 1 '12 at 22:51
    
no, that's 'si' and 'so' - swap in (to RAM) and swap out (to disk), respectively. I think that's listed in pages (4096 bytes, on x86), thou the manual is not terribly clear. –  qdot Mar 1 '12 at 23:04
    
What does it mean for swpd be to be non-zero? Is it necessarily a bad thing if your system is always using a non-zero amount of virtual memory? I'm guessing it's faster for the system to hit the cache as opposed to virtual memory. –  syker Mar 1 '12 at 23:13
    
It just means the system had swapped something out. I generally prefer highly responsive desktops, so I tune mine so that swap is always the last-resort option. When I'm working with large files, I don't mind waiting longer when the file is in out of cache and needs to be fetched, but I do mind when VM made a wrong guess about application code. It usually just tries to balance out somehow. It really depends on a machine - I usually go for most RAM money can buy, so my 2y laptop's 8GB and desktop's 32GB. –  qdot Mar 1 '12 at 23:46
show 3 more comments

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.