Difference between revisions of "Clear Memory Linux"
From MS Computech
(New page: ==== Clear Memory Linux ==== Writing to this will cause the kernel to drop clean caches, dentries and inodes from memory, causing that memory to become free. To free pagecache: <pre>* ec...) |
|||
Line 1: | Line 1: | ||
− | ==== Clear Memory Linux ==== | + | ==== Clear Memory Linux ==== |
− | Writing to this will cause the kernel to drop clean caches, dentries and inodes from memory, causing that memory to become free. | + | Writing to this will cause the kernel to drop clean caches, dentries and inodes from memory, causing that memory to become free. |
− | To free pagecache: | + | To free pagecache: |
<pre>* echo 1 > /proc/sys/vm/drop_caches</pre> | <pre>* echo 1 > /proc/sys/vm/drop_caches</pre> | ||
− | To free dentries and inodes: | + | To free dentries and inodes: |
<pre>* echo 2 > /proc/sys/vm/drop_caches</pre> | <pre>* echo 2 > /proc/sys/vm/drop_caches</pre> | ||
− | To free pagecache, dentries and inodes: | + | To free pagecache, dentries and inodes: |
<pre>* echo 3 > /proc/sys/vm/drop_caches</pre> | <pre>* echo 3 > /proc/sys/vm/drop_caches</pre> | ||
− | As this is a non-destructive operation, and dirty objects are not freeable, the user should run "sync" first in order to make sure all cached objects are freed. | + | As this is a non-destructive operation, and dirty objects are not freeable, the user should run "sync" first in order to make sure all cached objects are freed. |
+ | Run every 2 hour | ||
+ | <pre>nano /etc/crontab | ||
+ | |||
+ | 0 */2 * * * root echo 3 > /proc/sys/vm/drop_caches</pre> | ||
==========================<br> | ==========================<br> |
Revision as of 16:52, 19 February 2009
Clear Memory Linux
Writing to this will cause the kernel to drop clean caches, dentries and inodes from memory, causing that memory to become free.
To free pagecache:
* echo 1 > /proc/sys/vm/drop_caches
To free dentries and inodes:
* echo 2 > /proc/sys/vm/drop_caches
To free pagecache, dentries and inodes:
* echo 3 > /proc/sys/vm/drop_caches
As this is a non-destructive operation, and dirty objects are not freeable, the user should run "sync" first in order to make sure all cached objects are freed.
Run every 2 hour
nano /etc/crontab 0 */2 * * * root echo 3 > /proc/sys/vm/drop_caches
==========================