Saturday, May 25, 2013

Howto Free up used memory on a Linux operating system



Usually the kernel handles memory utilization pretty well it caches memory for dentry cache, page cache and inodes which improves IO speed and performance generally. But in some cases user applications needs lots of memory and we need to clear what’s called dirty memory which could be inodes already written to the disk, so now the kernel given us the option to manage this manually.
To Free
echo 1 > /proc/sys/vm/drop_caches
echo 2 > /proc/sys/vm/drop_caches
echo 3 > /proc/sys/vm/drop_caches
free -m
total used free shared buffers cached
Mem: 3833 2827 1005 0 31 1030
-/+ buffers/cache: 1765 2067
Swap: 10095 0 10095
~ $free -m

                     total       used          free     shared    buffers     cached
Mem:           5754       1551       4202          0        258        980
-/+ buffers/cache:          313       5441
Swap:           5215            0       5215



Here "buffers" and "cached" columns, which tell you about the amount of memory that the kernel is using for filesystem buffers, etc

So in this example, 5441MB is how much memory is technically available for allocation should an application need it. The "buffers" (258MB) and "cached" (980MB) will be released by the kernal if they are needed.

No comments:

Post a Comment