2

I've read a number of top memory use questions but I don't think they answer this.

Here's the most significant part of a top run:

top - 01:11:41 up 4 days,  1:06,  3 users,  load average: 0.00, 0.03, 0.26
Tasks:  86 total,   1 running,  84 sleeping,   0 stopped,   1 zombie
Cpu(s):  0.4%us,  0.4%sy,  0.0%ni, 99.2%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   1022816k total,   986704k used,    36112k free,    11200k buffers
Swap:  1048572k total,   419088k used,   629484k free,   408172k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                         
 2022 django    20   0  463m  87m  688 S  0.4  8.7   0:44.06 redis-server                                    
 6047 django    20   0  106m  25m 3900 S  0.4  2.6   0:16.57 python                                          
 6046 django    20   0 40892  13m 2852 S  0.0  1.4   0:00.14 python                                          
 6887 postgres  20   0 98752 5240 4100 S  0.0  0.5   0:00.60 postgres                                        
 6512 root      20   0 70820 2528 1776 S  0.0  0.2   0:00.03 sshd                                            
 3614 root      20   0 70820 2452 1696 S  0.0  0.2   0:00.03 sshd                                            
 6892 postgres  20   0 99028 2044  720 S  0.0  0.2   0:00.53 postgres                                        
12983 django    20   0 18332 1968 1156 S  0.0  0.2   0:00.06 bash                                            
 3627 joe       20   0 71148 1660  632 S  0.0  0.2   0:00.84 sshd                                            
 6890 postgres  20   0 98752 1640  500 S  0.0  0.2   0:02.59 postgres                                        
 3628 joe       20   0 18056 1588 1056 S  0.0  0.2   0:00.10 bash                                            
 6537 postgres  20   0 18000 1580 1100 S  0.0  0.2   0:00.04 bash                                            
 6893 postgres  20   0 70296 1564  296 S  0.0  0.2   0:00.38 postgres                                        
  708 mysql     20   0  166m 1560  408 S  0.0  0.2   3:08.15 mysqld                                          
 9221 root      20   0 31724 1456 1148 S  0.0  0.1   0:00.01 sudo

This states that 986704k out of 1022816k is used (I make that about 96%). However the top 3 processes' percentages add up to 12.7%. Something is using nearly all of my RAM and I can't tell what it is. free shows me similar numbers.

Any suggestions about trying to find out what's using this all?

(I notice there's 1 zombie process. Could it be that?)

2 Answers 2

7

The short answer is that the rest of your memory is used to cache your applications.

The long answer can be found here.

1
  • That could be it. I have written 200,000 files to disk recently.
    – Joe
    Jan 3, 2012 at 1:24
0

It's just whatever happens to be there, most likely data read from or written to disk. Making that memory free is a losing proposition on so many levels:

1) If the data is needed again, and the system makes the memory free, it will have to read it in from disk.

2) Making the memory free takes effort and then if the memory is needed for something else, the system will just have to make it used again, doubling the wastage. It's more efficient to transition memory directly from one use to another rather in one step.

3) The demand for memory is low. So there is very little need for free memory.

So modern operating systems only make memory free if there is absolutely nothing useful they could possibly hold in that memory at all or if there is a demand for free memory. Otherwise, free memory is wasted memory. It's not like if you use less today you can use more tomorrow.

You must log in to answer this question.

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