Wednesday, September 9, 2009

drop_caches free up memmory dentries and inodes

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.
This tunable was added in 2.6.16.

Buffer & Cache
A buffer is a place you store data you've just acquired through some slow method (such as downloading from the Internet) so you have a store to work on in real time.

e.g. When you watch a streaming video, you start downloading the video from the remote server, store it locally, and when you have some of the data (how much varies, it could be a couple of seconds worth, it could be minutes or more), you then start to play it. This avoids stuttering if the connection slows slightly for a moment.

A cache is a similar concept. You get some data that you plan to access more than once, and save a copy somewhere that is faster then getting it from the original place again. e.g. Someone might search for "Hello" on Yahoo, so Yahoo will go through some databases and find matches to give back to the user. They might then cache the results, so if someone else searches for the same thing, they can get them quickly from the cache instead of trawling through all the big databases again.

They aren't UNIX specific concepts, and how you implement them depends on what you want to buffer or cache and where.

No comments:

Post a Comment

tag ur valuable ideas below