Monday, July 1, 2013

Large memory usage problem in Red Hat 6.x

Step 1:  Check memory usages
# free -m
                         total       used       free     shared    buffers     cached
Mem:              16081      15848        232          0        379      13846

            Still memory utilization is very high.

 Step 2: Check value of ‘vm.vfs_cache_pressure’
# sysctl -a | grep vfs_cache_pressure
vm.vfs_cache_pressure = 100

 Step 3: Change 1000 instead of 100
# vi /etc/sysctl.conf
vm.vfs_cache_pressure = 1000

Step 4: Make value effective
# sysctl -p
vm.vfs_cache_pressure = 1000

Set /proc/sys/vm/vfs_cache_pressure at 1000, memory usage would usually hover around 700-900MB, but if anything needs lots of memory (e.g. copying lots amount of data to tmpfs) it's usage would drop back to around 100-130MB mark.

Step 5:  Check memory usages
# free -m
                         total       used       free     shared    buffers     cached
Mem:              16081      15884        197          0        379      13850

Step 6: Run below command again
# sync && echo 3 > /proc/sys/vm/drop_caches
 
Meaning of above command parameters
            echo 1 > /proc/sys/vm/drop_caches  # free pagecache, [OR]
            echo 2 > /proc/sys/vm/drop_caches  # free dentries and inodes, [OR]
            echo 3 > /proc/sys/vm/drop_caches  # free pagecache, dentries and inodes

            sync  # forces the dump to be destructive

Step 7:  Check memory usages
# free -m
                                         total       used       free     shared    buffers     cached
Mem:               16081       1166      14915          0          4        149

 

No comments:

Post a Comment