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 a web server running Apache that has some interesting numbers for memory usage.

Looking at top I have the following memory information

Mem:  11679976k total, 10917568k used,   762408k free,   384320k buffers
Swap:  4194296k total,        0k used,  4194296k free,  1103728k cached

So subtracting buffers and cache there is approxmiately 9GB or so of memory being used. free -m confirms this.

             total       used       free     shared    buffers     cached
Mem:         11406      10642        763          0        375       1077
-/+ buffers/cache:       9189       2217
Swap:         4095          0       4095

This web server is quite busy so when we turn off apache we would expect this memory usage to drop drastically, but it doesn't drop much at all.

How can I find what is really using up all that memory? From tops output after shutting down apache nobody is using much memory. This tells me no one is using that memory, but the system is reporting it is being used.

We have had several servers crash because the memory was used up so we're trying to understand better what is going on.

share|improve this question
    
when you run top, do you sort fields by memory or use default CPU? –  Petter H Oct 24 '13 at 18:14
    
Please provide the output of /proc/meminfo –  Matthew Ife Oct 24 '13 at 18:47
add comment

1 Answer

up vote 1 down vote accepted

Check out /proc/meminfo and /proc/slabinfo. The slabtop command may help you with understanding the slabinfo contents.

There are caches that can consume memory but aren't categorized as cache or buffers by top / free. inode and dentry come to mind (particularly if you have extensive filesystems).

share|improve this answer
    
Slabinfo indicates that I have huge number of dentry objects. Does the memory get reclaimed if an application needs it? –  morgana Oct 24 '13 at 18:55
    
I believe so, but the impact to performance when you lose that cache is always going to depend on the nature of your application. You can drop the cache by echoing various values to /proc/sys/vm/drop_caches (google them). You can also just run a simply "bloat" process to soak up memory and watch how the system behaves. For example, run perl -e 'foreach $x (1..BIGNUMBER) { $y{$x} = $x; }' and adjust up the number to increase the memory consumption. –  Joshua Miller Oct 24 '13 at 19:12
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.