Global Linux Knowledge Base…
Release memory in Linux (Unused or Cached)
|
In computer science, Memory Leakage occurs when a computer software or program consumes required memory but unable to memory after completing its task or when no longer needed to Operating System. There are two types of Memory Leakage. One is Virtual Memory Leakage and another is Real Memory Leakage. |
||||||||||||||||||||
|
Now first Identify cached memory or unused memory by executing, |
||||||||||||||||||||
|
# free -m |
||||||||||||||||||||
|
||||||||||||||||||||
|
Flush file system buffers by executing, |
||||||||||||||||||||
|
# sync |
||||||||||||||||||||
|
Kernels 2.6.16.x and newer versions of kernel provide a mechanism to have the kernel drop the page cache and/or inode and dentry caches on command, which can be helpful to free up a lot of memory. |
||||||||||||||||||||
|
To free page cache: |
||||||||||||||||||||
|
# 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 |
||||||||||||||||||||
|
Above commands are non-destructive and will only release unused memory. As we have used sync, so it will flush all Dirty Objects which are not free able and make it as unused memory. |
||||||||||||||||||||
| Print article | This entry was posted by Dhaval Soni on October 7, 2010 at 7:24 PM, and is filed under All, CentOS, Fedora, Linux, Linux OS, Red Hat, Utilities. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |
-
http://Website F14