clean up memory on linux

sync; echo 3 | sudo tee /proc/sys/vm/drop_caches
where proc filesystem mounted under /proc
Sample Output

By: bandie91
2010-05-23 11:39:35

8 Alternatives + Submit Alt

What Others Think

Why would you want to do this?
DNSpyder · 601 weeks and 6 days ago
Nice, but what would you use it for other than prettying up /usr/bin/free for management's consumption?
sufoo · 601 weeks and 6 days ago
Buffers and caches in linux only use unused memory, i.e. memory not used by processes. So it's incorrect to think that you are making more memory available for programs by using this, in general. As soon as an application makes a big memory request, the kernel may satisfy that request by "dropping" enough buffers or cache to satisfy the request. Because unused memory is a terrible thing to waste. :-) If you do this, and then want to cache a file's contents (if there is memory available) then simply do cat filename > /dev/null if you run htop you can see the cache fill up as cat reads this file and automatically uses cache if it can.
bwoodacre · 601 weeks and 5 days ago
bwoodacre: its news for me. i had hope it decrease number of pagefaults
bandie91 · 601 weeks and 4 days ago
under what situation i should use this command??
criver · 599 weeks and 6 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: