fijal
fijal

Reputation: 3190

How do I get information on linux whether my program is swapping or not?

More specifically: I want to find this information from inside the program, preferably just before it starts swapping so I can react. So far I found:

Any more ideas?

Upvotes: 5

Views: 191

Answers (1)

Brad
Brad

Reputation: 11515

vmstat

To run every 2 seconds, you say "vmstat 2". It gives you output like:

procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 0  0      0  16124 431352 439000    0    0     4     2   37   18  0  0 100  0  0

The "si" and "so" columns are "swap-in" and "swap-out". Swapd is how much memory is in the swap device. Swapd should be stable, and si and so zero.

Remember:

You shouldn't really ask "is my program swapping" - as opposed to "is the system swapping". You program can cause others to swap - others can cause yours to swap, etc. Either way, when that happens - performance d...i..e...s....

Upvotes: 2

Related Questions