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.

I'm running 32-bit Ubuntu 10.04 on a 4-core AMD Phenom machine with 4GB of RAM. With normal use (a dozen or so Chrome tabs, 1 VirtualBox machine, 2 or 3 instances of QtCreator, ) the memory will occasionally fill >95% and the machine will become mostly unresponsive.

If I look at the System Monitor during these periods, it shows the memory usage at 95%+ but only a few hundred MB of my 9GB swap partition are used! Why isn't more memory shifted into swap to avoid running out?

See: http://imagebin.org/148884

share|improve this question
    
You might want to install the pae kernel to get that missing 800MiB of RAM. –  Bobby Apr 18 '11 at 20:13
add comment

2 Answers 2

Getting memory from swap is very slow. Linux uses all available memory saving a small amount to run commands quickly. It will swap when memory is needed and not available through other means.

Linxu also buffers all the files you read and write in memory in a LRU cache. These buffers can be quickly released if memory is needed by programs. Given the programs you are running you may be running low on buffers, and I/O which is usually normally served out of buffers is being read from disk.

There is a swapiness parameter you can tune, but you may want to examine what is happening first. Try installing the sar package and running it in the background. You can then examine the files it generates to see what resource is becoming a bottleneck.

share|improve this answer
add comment

To add to Bill's response:

Swap should be avoided when possible because of the overhead. I believe the newer versions of Ubuntu have a defaulted value of 'swappiness' set to 10 (only start using Swap when <10% of RAM is available). I believe this is pretty consistent with what you are seeing.

If for some reason you want to start using swap earlier (ie. in order to have enough free ram to start a new VM image) then you can consider increasing the 'swappiness' value. The following guide describes how this is done and provides additional information (See section "Why is my swap not being used?").

https://help.ubuntu.com/community/SwapFaq

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.