Server Fault is a question and answer site for system and network administrators. 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 not a linux expert so i'm asking you for opinion. This is output of free -m command on my computer:

             total       used       free     shared    buffers     cached
Mem:          2026       1643        383          0        313        926
-/+ buffers/cache:        402       1624
Swap:         2855          0       2855

Is the RAM usage normal? (apache and mysql running, no users logged in at the time)

share|improve this question

migrated from Nov 19 '09 at 18:25

This question came from our site for professional and enthusiast programmers.

Looks fine to me. I would read up on how to read the memory usage for a Linux box because you need to look at the buffers/cache as well in order to get a better idea.

You are doing just fine. A good thing to see is that no Swap is being used.

share|improve this answer
+1. To clarify, the "used" number in "free -m" includes the system cache. Modern operating systems always use otherwise unused memory as a file system cache. – intgr Nov 19 '09 at 17:36
1.6 GB ram used by server when nothing is going on? To me it's little wierd ;) – Adrian Nov 19 '09 at 17:37
Thank's for help :) – Adrian Nov 19 '09 at 17:40
Sorry, I should have been more specific ... intgr adds most of it above. Everything looks good, the 1.6Gb includes a filesystem buffer, which is available to processes if they need it. Nothing to worry about at the moment. – Bob Martens Nov 19 '09 at 18:12
You are only using 402MB for processes. The OS is making use of that 1.6GB for processes plus buffers and filesystem cache. 1.2GB of that is still available for processes to take if they need it. You need to read up on linux memory management. – Aaron Brown Nov 19 '09 at 19:43

Linux uses memory a little differently than you may expect. Why? It actually uses as much memory as it possibly can :)

The slowest point to any process, in any OS is waiting for I/O .. its not only slow, its downright dangerous at times. Imagine a process waiting in I/O bound calls that will never return .. and what happens if that process dies? That's why we have disk sleep to prevent kernel rot from within.

What remains is responsiveness be it server or desktop, the best compromise is to put frequently accessed files in memory so that processes do not become I/O bound. Its not at all unfair, in fact you can tweak how Linux uses cache vs swap, but 8/10 times keeping files in clean pages make things run much faster.

When a process skids to disk for memory (swap).. that's a bad sign. It happens often when you combine things that allocate much more memory than they actually need (per thread or fork) to deal with incoming requests of unknown size. It happens when running Apache + MySQL on the same computer, for instance. Other processes can't get contiguous blocks of memory from the kernel due to the two fat men standing in the middle of the doorway. When a process has to read a block device to access memory, everything gets slower, especially processes with clean allocated blocks waiting to write stuff to disk.

Some programmers use mlock() or even mlockall() to prevent this but usually the kernel knows better. Likewise, some people use O_DIRECT with open() to bypass buffering .. and unless you are writing a relational DB engine, the kernel usually knows better than you regarding what needs buffers or not. Actually, posix_fadvise() and posix_madvise() are better, as they suggest what you think you know to the kernel, rather than dictate. After all, your process is not the only thing running on any given computer :)

Probably a lot more information than you wanted. I meant to say, the usage looks absolutely normal. However, look at /proc/sys/vm for knobs to control this behavior, if you want to tinker :)

share|improve this answer

You aren't swapping at all, and the vast majority of RAM that you're using is buffers/cached. Seems pretty healthy. There's a good article on how to understand the "free" command here.

share|improve this answer

The term "memory usage", as defined by some Linux tools, is a bit different than what most people expect.

Usually, when people think about memory usage, they think about the space occupied in memory by the applications.

Some (most?) Linux tools add to that the disk cache. So of course the total is higher. Moreover, Linux will tend to fill up memory otherwise unused with the cache and things like that. So, according to this definition, the "memory usage" on a Linux box always tends to grow to 99% or so after a while.

You may try to use htop instead. It gives you a color-coded bar chart of the memory usage: green for "old school" used memory (processes), blue for buffers, orange for cache.

share|improve this answer

Don't Panic!
Your ram is fine!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.