1

I have an apache2 server, and recently it seems that there is memory leak. I use mod_wsgi to write server WEB service in Python. At first I think it's my python program that leak the memory. But after top command, I can't find any process who leak the memory. Here is my top command. 128 GB memory is used. but apache2 process only use 14.1 GB memory, and i can't find any other processes who use such large memory. how to find it?

top - 16:33:01 up 2 days, 22:20,  1 user,  load average: 0.07, 0.03, 0.05
Tasks: 1975 total,   1 running, 1974 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.1%us,  0.1%sy,  0.0%ni, 99.8%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:  131987724k total, 131571384k used,   416340k free,    11068k buffers
Swap:   999420k total,   998324k used,     1096k free,    67008k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                                                                                                                   
30188 www-data  20   0 14.1g  31m    0 S    4  0.0   5:41.80 apache2                                                                                                                                                                   
31972 root      20   0 18844 2820  960 R    1  0.0   0:00.09 top                                                                                                                                                                       
    1 root      20   0 24348  820   56 S    0  0.0   0:02.21 init                                                                                                                                                                      
    2 root      20   0     0    0    0 S    0  0.0   0:00.33 kthreadd                                                                                                                                                                  
    3 root      20   0     0    0    0 S    0  0.0   0:00.67 ksoftirqd/0                                                                                                                                                               
    4 root      20   0     0    0    0 S    0  0.0   0:34.55 kworker/0:0                                                                                                                                                               
    5 root       0 -20     0    0    0 S    0  0.0   0:00.00 kworker/0:0H                                                                                                                                                              
    6 root      20   0     0    0    0 S    0  0.0   0:00.00 kworker/u96:0                                                                                                                                                             
    8 root      RT   0     0    0    0 S    0  0.0   0:00.58 migration/0                                                                                                                                                               
    9 root      20   0     0    0    0 S    0  0.0   0:00.00 rcu_bh                                                                                                                                                                    
   10 root      20   0     0    0    0 S    0  0.0   0:00.00 rcuob/0                                                                                                                                                                   
   11 root      20   0     0    0    0 S    0  0.0   0:00.00 rcuob/1                                                                                                                                                                   
   12 root      20   0     0    0    0 S    0  0.0   0:00.00 rcuob/2                                                                                                                                                                   
   13 root      20   0     0    0    0 S    0  0.0   0:00.00 rcuob/3                                                                                                                                                                   
   14 root      20   0     0    0    0 S    0  0.0   0:00.00 rcuob/4                                                                                                                                                                   
   15 root      20   0     0    0    0 S    0  0.0   0:00.00 rcuob/5                                                                                                                                                                   
   16 root      20   0     0    0    0 S    0  0.0   0:00.00 rcuob/6                                                                                                                                                                   
   17 root      20   0     0    0    0 S    0  0.0   0:00.00 rcuob/7                                                                                                                                                                   
   18 root      20   0     0    0    0 S    0  0.0   0:00.00 rcuob/8                                                                                                                                                                   
   19 root      20   0     0    0    0 S    0  0.0   0:00.00 rcuob/9                                                                                                                                                                   
   20 root      20   0     0    0    0 S    0  0.0   0:00.00 rcuob/10                                                                                                                                                                  
   21 root      20   0     0    0    0 S    0  0.0   0:00.00 rcuob/11   
2

Don't worry it is just file caching from linux, it is not directly linked to Apache:

http://www.linuxatemyram.com/

Linux is caching files like that you access them directly from memory instead of hard drive, it increase a lot the performances.

On Debian 6 & 7 my memory was always used for caching, in Debian 8 it seems they reduced the caching size, so there is still free RAM available.

  • But when application wants more memory, it will take back disk cache memory, but in this way, disk cache need to write back to disk before application take back the memory right? Is it a side effects – demonguy Dec 7 '15 at 3:36
  • Yes, if you are using Debian 6 or 7, you should upgrade to version 8, and your trouble will be fixed, as it keep some free memory available. – Froggiz Dec 7 '15 at 10:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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