Difference between revisions of "Linux memory management"

From Noah.org
Jump to navigationJump to search
m
 
(3 intermediate revisions by the same user not shown)
Line 8: Line 8:
 
== drop caches ==
 
== drop caches ==
  
This should only be used for performance testing where you want to be sure caching is not distorting run times between runs.
+
(flush cache, dump cache, drop cache)
 +
 
 +
This should only be used for performance testing where you want to be sure caching is not distorting run times between runs. Note that this does not give your applications more memory, despite what '''free''' might say. This is a common beginner's mistake.
  
 
This action is guaranteed to be harmless and non-destructive. This will only free '''non-dirty''' pages, so if you want to be sure you free as much as possible you should run '''sync''' before dropping caches.
 
This action is guaranteed to be harmless and non-destructive. This will only free '''non-dirty''' pages, so if you want to be sure you free as much as possible you should run '''sync''' before dropping caches.
Line 16: Line 18:
 
To free dentries and inodes:
 
To free dentries and inodes:
 
echo 2 > /proc/sys/vm/drop_caches
 
echo 2 > /proc/sys/vm/drop_caches
To free pagecache, dentries and inodes:
+
To free everything -- pagecache, dentries and inodes:
 
echo 3 > /proc/sys/vm/drop_caches
 
echo 3 > /proc/sys/vm/drop_caches
 
</pre>
 
</pre>
/proc/sys/vm/drop_caches
+
 
</pre>
+
== See also ==
 +
 
 +
https://www.kernel.org/doc/Documentation/sysctl/vm.txt

Latest revision as of 14:15, 29 May 2014


slab
dentry
inode
pagecache

drop caches

(flush cache, dump cache, drop cache)

This should only be used for performance testing where you want to be sure caching is not distorting run times between runs. Note that this does not give your applications more memory, despite what free might say. This is a common beginner's mistake.

This action is guaranteed to be harmless and non-destructive. This will only free non-dirty pages, so if you want to be sure you free as much as possible you should run sync before dropping caches.

To free pagecache:
	echo 1 > /proc/sys/vm/drop_caches
To free dentries and inodes:
	echo 2 > /proc/sys/vm/drop_caches
To free everything -- pagecache, dentries and inodes:
	echo 3 > /proc/sys/vm/drop_caches

See also

https://www.kernel.org/doc/Documentation/sysctl/vm.txt