How to Release Memory in Linux of Unused or Cached Objects

Hi Guys,

 Many times we have seen that in our system there are lots of unused memory are used by the system but this memory are not usable because some garbage collection is occupying our memory in the system and the system is not able to release the memory. So I am writing some usable commands for releasing the memory of linux operating system which is very useful & easy.


Memory Leakage happend when a computer application or any process consumes required memory but unable to release the memory after completing its task.There are two types of Memory Leakage in the computer system one is Virtual Memory Leakage and another is Real Memory Leakage.

Now first we have to checked the cached or unused memory first by executing the following command on terminal.

# free –m

total        
used
           free
shared
Mem:
3991
2674
           1317      
0
-/+ buffers/cache:

753
           3238

Swap:
1023
    0
           1023


Flush the file system buffers by running the sync command,

# sync

Kernel provides a mechanism to drop the page cache and/or inode and dentry caches on command, which is helpful to free a lots of memory in the system.

To free page cache use the below mention commands on terminal:
# echo 1 > /proc/sys/vm/drop_caches

To free dentries and inodes:
# echo 2 > /proc/sys/vm/drop_caches

To free page cache, dentries and inodes:
echo 3 > /proc/sys/vm/drop_caches

These commands are non-destructive and it will release unused memory only and will not affect any process of the system. As we have execute the sync command so it will remove the all unused Objects which are not free and used unused memory.

Gud Luck....

Regards,
Sampan

Comments

Popular posts from this blog

How to Read Excel File in VC++....

Window could not start the Apache tomcat 6 on Local Computer.For more information, review the System Events Logs.If this is a non-Microsoft service,contact service vendor, and refer to service-specific error code 0.

How to Bind Multiple SMPP Acounts Using Kannel SMS Gateway.