Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Oct 102010
 

How to clear cache from memory in Linux?

Answer:

From time to time, you might observed memory in Linux aren't free'ed after used, and they can be shown in the cached column of the free command.

# free -m
             total       used       free     shared    buffers     cached
Mem:          1033        468        564          0          0        343
-/+ buffers/cache:        124        908
Swap:          255          1        254

To manually free it, try

# sync; echo 3 > /proc/sys/vm/drop_caches

And try the free command again.

# free -m
             total       used       free     shared    buffers     cached
Mem:          1033        135        897          0          0         10
-/+ buffers/cache:        124        908
Swap:          255          1        254

  2 Responses to “How to clear cache from memory in Linux?”

  1. I know the right command is something like that, but this one ain't right: look at the 2ยบ free -m = is just equal to the first one; and it doesn't work...
    This would be helpfull because my swap file isn't being cleared...

  2. [...] freeing memory on Gentoo is generally not needed, but I like this tip from linuxask.com. The code is below. Focus on the cached [...]

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>