Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

As part of doing some cold cache timings, I'm trying to free the OS cache. The kernel documentation says:


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.

I'm a bit sketchy about the details. Running

echo 3 > /proc/sys/vm/drop_caches

frees pagecache, dentries and inodes. Ok.

So, if I want the system to start caching normally again, do I need to reset it to 0 first? My system has the value currently set to 0, which I assume is the default. Or will it reset on its own? I see at least two possibilities here, and I'm not sure which one is true:

  1. echo 3 > /proc/sys/vm/drop_caches frees pagecache, dentries and inodes. The system then immediately starts caching again. I'm not sure what I would expect the value in /proc/sys/vm/drop_caches to do if this is the case. Go back to 0 almost immediately?

  2. If /proc/sys/vm/drop_caches is set to 3, the system does not do any memory caching till it is reset to 0.

Which case is true?

share|improve this question
To use it with sudo: echo 3 | sudo tee /proc/sys/vm/drop_caches –  Volker Siegel Aug 3 '14 at 22:40

1 Answer 1

up vote 17 down vote accepted

It isn't sticky - you just write to the file to make it drop the caches and then it immediately starts caching again.

Basically when you write to that file you aren't really changing a setting, you are issuing a command to the kernel. The kernel acts on that command (by dropping the caches) then carries on as before.

share|improve this answer
Ok, thanks. Does the value immediately change back to 0? –  Faheem Mitha Aug 3 '11 at 8:49
@FaheemMitha No, the value you can read is whatever you put last, but it's not used anywhere, only the action of writing matters. The source code is in fs/drop_caches.c. –  Gilles Aug 4 '11 at 0:16
@Gilles: Thanks. –  Faheem Mitha Aug 4 '11 at 6:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.