Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have an Ubuntu 10.04 web server in the cloud, with 1 GB of RAM. Here's a memory chart from Munin:

enter image description here

but I'm having trouble making sense of it: on the one hand, unused memory is very high; but swap memory is simultaneously very high, and "committed" memory is way over what's actually available.

Isn't swap supposed to be used only if there's no real memory left? Is this a normal memory usage graph, or is something probably wrong here?

share|improve this question

2 Answers 2

Isn't swap supposed to be used only if there's no real memory left?

That's incorrect. When the kernel sees memory pages that have gone unused for a long time, it'll proactively swap them out (even if there is plenty of other free RAM), making that RAM space available for disk cache.

share|improve this answer
    
Disk cache, or any process that needs them; the system tries hard to keep some core available to honour reasonable requests for pages without having to go swapping first. I also note that your kernel's committed memory runs about 1.4GB, and you've only 1GB of core; if everyone who's malloc'ed core calls for it at once, the kernel will experience a nasty run on memory. Having run something very similar myself, I found that adding enough core to bring the available over the committed speeded the machine up dramatically. If you can put an extra 1GB in, do so. –  MadHatter Dec 7 '11 at 16:44
    
Kernel committed being higher than real memory is a 'feature' of the Linux memory management approach. Look at vm.overcommit_memory. –  EightBitTony Dec 7 '11 at 18:40

Having watched a system slowly die due to a memory leak, I can confirm that free memory is always required. UNIX/Linux requires some free memory to load programs. Unix tends to do a lot of process creation, and uses free memory to load these programs. If you don't have free memory process execution will be very slow as memory will need to be reclaimed before the program can be reloaded.

Shared memory helps a lot as many programs can use the same read-only memory pages. However, writable pages need to be allocated on a per process basis. Disk buffers also help as the code needed may already be in memory.

For long running programs it is OK if initialization and shutdown code is paged out. This assumes the memory pages for this code are not shared by code which is actively used. Some programs may have rarely used code which can be swapped out. Programs which run rarely can also swap out with minimal impact.

Once you start to actively swap pages in and out of memory performance will degrade severely.

share|improve this answer

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.