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.

Possible Duplicate:
Linux high memory usage (top total mismatch)
High Memory Usage on Linux Server

CentOS 5.7 dedicated server. No memory intensive processes running. 12GB RAM installed.

Mem:  12462256k total, 12425344k used,    36912k free,   395528k buffers
Swap:  1999864k total,      344k used,  1999520k free, 10795472k cached

I contacted our server provider and they said:

The cached content is about 10 GB and this is information that is often accessed by the system, this way the server is able to faster access it when the information is needed. This information can always be freed and memory to be allocated for other needs.

Does that make sense?

I checked another server with only 4GB of RAM. It's also "doing nothing" but sure enough has 99% of RAM marked as "used". But in that case very little of it is marked as "cached".

Mem:   3969436k total,  3945568k used,    23868k free,   352740k buffers
Swap:  2097144k total,  1206984k used,   890160k free,    53232k cached

Can anyone make sense of this?

share|improve this question

marked as duplicate by MadHatter, SvW, Iain Dec 6 '12 at 10:39

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2  
Please read linuxatemyram.com –  SvW Dec 6 '12 at 10:29
    
Have you looked at /proc/slabinfo? Eg machines with large filesystems mounted can allocate a huge amount of "dentry".... –  rackandboneman Dec 6 '12 at 10:30

3 Answers 3

Server is dedicated to running what? Albeit weird indeed, I have seen this behaviour in virtualbox vm server. Still, I think the answer of the serve provider is adequate. They seem to be using the available ram as a fast storage location. There must be an application (or a system driver) that chews your RAM.

"Top" is a bit hard to navigate into. Try "htop" where you can check out things more easily. There is colour coding on the RAM usage meter, so you can check out if user or system is using up this RAM.

share|improve this answer
    
"dedicated server" is just what they call standalone servers. I.e. it is not a shared server with other customers using it. We have sole access to it. It has 12GB of RAM but is literally being used for nothing right now except a very low traffic web server. It is a testing server, so the only ones who visit it are us. –  Buttle Butkus Dec 6 '12 at 10:55
1  
There is no application or system driver that chews RAM. The RAM is in use because there is no benefit to free RAM. The system could make it free if it had any reason to, but since it has no reason, it doesn't do that. –  David Schwartz Dec 6 '12 at 11:13

You're thinking, "I'd like to have more RAM free so I can use it later". But you don't need to have RAM free now to use it later. In fact, it's easier to use it later if it's in use now -- you don't have to do anything at all to use it later. So your question is basically "Why are things so good? Shouldn't they be worse?"

Free RAM is a pure cost. If you leave 1GB free for 10 minutes, you've forever lost the chance to use that memory for that time. You can't use an extra 1GB later. So modern operating systems only leave RAM free if they have no other choice, as it's just wasted. Only about 32MB is needed, and that's for cases where RAM is needed in contexts in which it's not possible to directly transition from one use to another (for example, during a disk interrupt).

share|improve this answer
    
David, this whole answer is utterly confusing, especially if someone doesn't know the background already. Especially the first paragraph doesn't make any sense at all - why should it be easier to use RAM later if you use it know? –  SvW Dec 6 '12 at 10:57
    
@SvenW: If you're using it now, you don't have to do anything to use it later (just leave the machine on and don't free it). If you're not using it now, you have to transition it from unused to used to use it later. Many people think "I want free RAM so I can use it later". But actually, it's RAM that's used now that is easiest to use later. If you have any suggestions for how I can make this clearer, please share them. –  David Schwartz Dec 6 '12 at 11:11
    
First, I agree that used RAM (as buffer/cache) is a good thing, but I don't believe that it's easier for the kernel to free RAM from the system wide caches (this has to be managed!) then to allocate an additional area of free RAM for use by process xy. –  SvW Dec 6 '12 at 11:22
    
@SvenW: I never said that. I just said it's easier to use RAM if you're already using rather than if it's free. To use RAM that's already in use, nothing has to be freed or allocated at all. For example, if a system has 8GB used and 4GB free, the easiest thing for it to do is to keep that same 8GB used and that same 4GB free. It has to do nothing to achieve this result. If you want RAM to be used later, the best way to accomplish that is to use it now. –  David Schwartz Dec 6 '12 at 11:25
    
For example, if you shrink the caches, making lots of free RAM, it will become much harder for the system to use that RAM you freed. If you had kept that RAM in use, it would remain useful cache. By freeing it, you force the system to be unable to use it later until there's sufficient disk access to repopulate it. So making memory free makes it harder to use it later. Keeping memory in use makes it easier to use it later. –  David Schwartz Dec 6 '12 at 11:27

Sure, Linux uses all RAM: both for applications and for file system cache. You may better check it with "cat /proc/meminfo". Have a look at "Cached" and "Buffers" lines

share|improve this answer
    
And again the "Slab" or "Slub" lines depending on what kernel/allocator type is used ... "Cached" and "Buffers" alone, as well as the linuxatemyram.com advice, can be misleading when kernel allocations are involved. –  rackandboneman Dec 6 '12 at 10:33

Not the answer you're looking for? Browse other questions tagged or ask your own question.