Search This Blog

Tuesday, June 13, 2017

Freeup RAM in Linux System - Linux Basics


            Some times linux Servers/Low memory linux boards tends to low memory conditions. Even though linux has excellent memory management system Some un-closed files, network memeroies and caches  causes out of memory or low memory conditions. By deleting and cleaning pagecache, dentries and inodes we can get the unused memory.

we can check ram usage with free command

root@arm:~# free
                   total         used         free      shared    buffers     cached
Mem:         50204      47352       2852          0       6188      20768
-/+ buffers/cache:      20396      29808
Swap:            0              0              0

here i am having only 2852KB of memory free  out of 64MB RAM.

Option 1: Free pagecache

This is suitable for webserver as they tend to store lots of pagecaches.

To free pagecache:

sync; echo 1 > /proc/sys/vm/drop_caches


(
To free pagecache, dentries and inodes(not recommended)
sync; echo 3 > /proc/sys/vm/drop_caches 
)

after this 

root@arm:~# echo 1 > /proc/sys/vm/drop_caches
root@arm:~# free
                      total       used       free     shared    buffers     cached
Mem:         50204      26412      23792          0         80       6720
-/+ buffers/cache:      19612      30592
Swap:            0                0          0

the free memory is 23MB.

No comments:

Post a Comment