-1

I have some strange output from the top command on my web server. Output is ordered by %MEM:

top - 13:57:43 up 13 days, 21:58,  1 user,  load average: 0.00, 0.00, 0.00
Tasks: 118 total,   1 running, 117 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.0%us,  0.0%sy,  0.0%ni,100.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   2854520k total,  *2767576k used*,    *86944k free*,   328060k buffers
Swap:  5574648k total,        0k used,  5574648k free,  2194252k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND            
 2528 mysql     20   0  136m  26m 6260 S    0  0.9   0:01.74 mysqld             
 2804 www       20   0 40732  15m 4412 S    0  0.6   0:00.72 apache2            
 2708 www       20   0 40724  14m 4060 S    0  0.5   0:00.13 apache2            
 2844 www       20   0 40696  14m 3984 S    0  0.5   0:00.26 apache2            
 2847 www       20   0 40696  14m 3960 S    0  0.5   0:00.12 apache2            
 2815 www       20   0 39816  14m 4240 S    0  0.5   0:00.58 apache2            
 7516 root      20   0 35264  14m 7776 S    0  0.5   0:11.79 apache2            
 1096 bind      20   0 51192 9504 2328 S    0  0.3   0:00.09 named              
 2838 www       20   0 35800 8852 1716 S    0  0.3   0:00.00 apache2            
 2846 www       20   0 35336 8440 1528 S    0  0.3   0:00.00 apache2            
 2850 www       20   0 35336 8440 1528 S    0  0.3   0:00.00 apache2            
 2849 www       20   0 35312 7960 1072 S    0  0.3   0:00.00 apache2            
 2891 www       20   0 35296 7772  892 S    0  0.3   0:00.00 apache2            
 1147 root      20   0 48532 6948 2300 S    0  0.2   0:00.09 lwresd                            
 1414 postgres  20   0 46444 5456 4640 S    0  0.2   0:08.90 postgres           
 1564 root      20   0 18512 5096 4280 S    0  0.2   0:02.96 smbd              

Notice the used and free totals in the header of the output.

Something is chewing up basically all of my memory, but this output does not seem to help me diagnose the problem.

What could possibly be consuming all the memory?

Server is Debian 5 with standard LAMP stack and samba installed.

1
  • This was a case of not understanding cause and effect. My server was slow and this output alarmed me, however, as the answers have explained, the memory is actually fine. Feb 14, 2013 at 19:19

2 Answers 2

1

The operating system has tons of spare memory, so there's no point in making any memory free. Say the operating system made some memory free, one of two things would happen:

  1. Nothing would use that memory any time soon. In this case, making the memory free was a waste of time as it wasn't used.

  2. Something would use that memory soon. In this case, making the memory free was a waste of time as the system just has to make it used again.

In either case, the effort is wasted. This is why modern operating systems make memory free only when they have absolutely no other choice. In this case, the operating system has another choice -- it can use the memory to hold data recently read from or written to disk in the hopes that something will need to access that data again and a disk access can be saved.

If you're thinking "I want memory free now so I can use it later", get that out of your head. You can use it now and use it later. There's no need to make a painful tradeoff.

1
  • Thanks. I misinterpreted what "free" memory really meant. Feb 14, 2013 at 19:21
2

Your linux is simply caching files.

http://www.linuxatemyram.com/

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