Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
    
I have the same problem. I think it's related to old Ubuntu versions, a friend with the same problem seems to have it fixed in latest Ubuntu (14.10). – ctn Feb 18 '15 at 10:08

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.

Linux 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 swappiness parameter you can tune, but you may want to examine what is happening first. Try installing the sar utility (package sysstat) 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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .