Clearning the Linux Memory cache can be a quick way to regain system resources.
Writing to the drop_cache process 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” command first in order to make sure all cached objects are freed.
Example –
Memory before:
[root@localhost ~]# free -m
total used free shared buffers cached
Mem: 1010 361 648 0 25 271
-/+ buffers/cache: 64 945
Swap: 2047 0 2047
Memory after:
Writing to the drop_cache process 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” command first in order to make sure all cached objects are freed.
Example –
Memory before:
[root@localhost ~]# free -m
total used free shared buffers cached
Mem: 1010 361 648 0 25 271
-/+ buffers/cache: 64 945
Swap: 2047 0 2047
Memory after:
[root@localhost ~]# sync
[root@localhost ~]# echo 3 > /proc/sys/vm/drop_caches
[root@localhost ~]# free -m
total used free shared buffers cached
Mem: 1010 81 929 0 0 20
-/+ buffers/cache: 60 950
Swap: 2047 0 2047
No comments:
Post a Comment