Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
linux:clear_memory_cache [2014/03/13 18:59]
bkraul
linux:clear_memory_cache [2017/12/13 17:34] (current)
Line 2: Line 2:
 Clearing 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. Clearing 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: ​===+To free pagecache:
 <code console>​echo 1 > /​proc/​sys/​vm/​drop_caches</​code>​ <code console>​echo 1 > /​proc/​sys/​vm/​drop_caches</​code>​
  
-=== To free dentries and inodes: ​===+To free dentries and inodes:
 <code console>​echo 2 > /​proc/​sys/​vm/​drop_caches</​code>​ <code console>​echo 2 > /​proc/​sys/​vm/​drop_caches</​code>​
  
-=== To free pagecache, dentries and inodes: ​===+To free pagecache, dentries and inodes:
 <code console>​echo 3 > /​proc/​sys/​vm/​drop_caches</​code>​ <code console>​echo 3 > /​proc/​sys/​vm/​drop_caches</​code>​
 \\ \\
 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.
  
-=== Example - Memory before: ​===+Example - Memory before:
 <code console> <code console>
 [root@server ~]# free -m [root@server ~]# free -m
Line 23: Line 23:
 </​code>​ </​code>​
  
-=== Cleanup command: ​===+Cleanup command:
 <code console> <code console>
 [root@server ~]# sync [root@server ~]# sync
Line 29: Line 29:
 </​code>​ </​code>​
  
-=== Memory after: ​===+Memory after:
 <code console> <code console>
 [root@server ~]# free -m [root@server ~]# free -m
  • linux/clear_memory_cache.txt
  • Last modified: 2017/12/13 17:34
  • (external edit)