centos vps memory is too full

MOHRE asked:

my ram is almost full without any process using it.

maybe you think it’s a duplicate question but unlike others my -/+ buffers/cache is used too. this is output of related commands:

top – 00:27:38 up 2 days, 21:54, 1 user, load average: 0.07, 0.05, 0.05
Tasks: 90 total, 1 running, 89 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.3%us, 0.0%sy, 0.0%ni, 99.7%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 1020116k total, 882460k used, 137656k free, 11868k buffers
Swap: 2064380k total, 22528k used, 2041852k free, 137824k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                         
15249 root      20   0 15024 1284  984 R  0.3  0.1   0:00.04 top                                                              
    1 root      20   0 19360  712  500 S  0.0  0.1   0:06.88 init                                                             
    2 root      20   0     0    0    0 S  0.0  0.0   0:00.04 kthreadd                                                         
    3 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/0                                                      
    4 root      20   0     0    0    0 S  0.0  0.0   0:01.85 ksoftirqd/0                                                      
    5 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 stopper/0                                                        
    6 root      RT   0     0    0    0 S  0.0  0.0   0:01.19 watchdog/0                                                       
    7 root      20   0     0    0    0 S  0.0  0.0   0:18.39 events/0                                                         
    8 root      20   0     0    0    0 S  0.0  0.0   0:00.00 events/0                                                         
    9 root      20   0     0    0    0 S  0.0  0.0   0:00.00 events_long/0                                                    
   10 root      20   0     0    0    0 S  0.0  0.0   0:00.00 events_power_ef                                                  
   11 root      20   0     0    0    0 S  0.0  0.0   0:00.00 cgroup                                                           
   12 root      20   0     0    0    0 S  0.0  0.0   0:00.00 khelper                                                          
   13 root      20   0     0    0    0 S  0.0  0.0   0:00.00 netns                                                            
   14 root      20   0     0    0    0 S  0.0  0.0   0:00.00 async/mgr                                                        
   15 root      20   0     0    0    0 S  0.0  0.0   0:00.00 pm                                                               
   16 root      20   0     0    0    0 S  0.0  0.0   0:00.76 sync_supers                                                      
   17 root      20   0     0    0    0 S  0.0  0.0   0:00.62 bdi-default                                                      
   18 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kintegrityd/0                                                    
   19 root      20   0     0    0    0 S  0.0  0.0   0:01.59 kblockd/0                                                        
   20 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kacpid                                                           
   21 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kacpi_notify                                                     
   22 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kacpi_hotplug                                                    
   23 root      20   0     0    0    0 S  0.0  0.0   0:00.00 ata_aux                                                          
   24 root      20   0     0    0    0 S  0.0  0.0   0:00.00 ata_sff/0                                                        
   25 root      20   0     0    0    0 S  0.0  0.0   0:00.00 ksuspend_usbd                                                    
   26 root      20   0     0    0    0 S  0.0  0.0   0:00.00 khubd                                                            
   27 root      20   0     0    0    0 S  0.0  0.0   0:00.02 kseriod                                                          
   28 root      20   0     0    0    0 S  0.0  0.0   0:00.00 md/0                                                             
   29 root      20   0     0    0    0 S  0.0  0.0   0:00.00 md_misc/0                                                        
   30 root      20   0     0    0    0 S  0.0  0.0   0:00.00 linkwatch                                                        
   32 root      20   0     0    0    0 S  0.0  0.0   0:00.06 khungtaskd                                                       
   33 root      20   0     0    0    0 S  0.0  0.0   0:24.98 kswapd0                                                          
   34 root      25   5     0    0    0 S  0.0  0.0   0:00.00 ksmd                                                             
   35 root      39  19     0    0    0 S  0.0  0.0   0:09.29 khugepaged                                                       
   36 root      20   0     0    0    0 S  0.0  0.0   0:00.00 aio/0                                                            
   37 root      20   0     0    0    0 S  0.0  0.0   0:00.00 crypto/0                                                         
   44 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kthrotld/0                                                       
   45 root      20   0     0    0    0 S  0.0  0.0   0:00.00 pciehpd                                                          
   47 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kpsmoused                                                        
   48 root      20   0     0    0    0 S  0.0  0.0   0:00.00 usbhid_resumer                                                   
   49 root      20   0     0    0    0 S  0.0  0.0   0:00.00 deferwq                                                          
   82 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kdmremove                                                        
   83 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kstriped                                                         

and

# free -m:
             total       used       free     shared    buffers     cached
Mem:           996        861        134          0         11        134
-/+ buffers/cache:        715        280 
Swap:         2015         22       1993 

and

root@reverser ~]# ps_mem
 Private  +   Shared  =  RAM used Program 

  4.0 KiB +  31.5 KiB =  35.5 KiB dbus-daemon
  4.0 KiB +  56.5 KiB =  60.5 KiB vsftpd
 84.0 KiB +  28.0 KiB = 112.0 KiB anvil
 36.0 KiB +  86.5 KiB = 122.5 KiB udevd (3)
 24.0 KiB +  99.0 KiB = 123.0 KiB mingetty (6)
116.0 KiB +  31.5 KiB = 147.5 KiB dovecot
128.0 KiB +  29.0 KiB = 157.0 KiB log
132.0 KiB +  39.0 KiB = 171.0 KiB crond
124.0 KiB + 104.0 KiB = 228.0 KiB exim
224.0 KiB +  37.0 KiB = 261.0 KiB auditd
324.0 KiB +  45.0 KiB = 369.0 KiB init
392.0 KiB + 205.0 KiB = 597.0 KiB fail2ban-server
716.0 KiB +  48.5 KiB = 764.5 KiB rsyslogd
452.0 KiB + 353.0 KiB = 805.0 KiB nginx (4)
968.0 KiB +  84.0 KiB =   1.0 MiB bash
  1.5 MiB + 313.0 KiB =   1.8 MiB sshd (2)
  1.7 MiB + 395.5 KiB =   2.1 MiB vesta-nginx (2)
  2.1 MiB +   1.8 MiB =   3.9 MiB vesta-php (3)
  7.5 MiB +  91.0 KiB =   7.6 MiB named
---------------------------------
                         20.3 MiB
=================================

what should I do to decrease memory usage?

My answer:


This looks like memory ballooning is active. This occurs when the hypervisor is under memory pressure; it claims unused memory from some guests to allocate to others. Generally the memory is automatically returned when the guest asks for it back.

This is commonly seen with VPS providers who overcommit their resources, knowing that most users will not use all of the RAM, CPU, disk, etc., allocated to them.

Unfortunately it’s difficult to detect ballooning in guests under VMware (some other hypervisors have methods where guests can directly account for ballooning). But you can try starting a program which uses a lot of RAM; if it starts successfully and your free numbers don’t go upward as much as the RAM actually used, then you have detected the balloon driver releasing RAM back to your VPS.


View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.