I have read a lot of docs saying, it is good idea to do a sync before doing echo [1,2,3] > /proc/sys/vm/drop_caches. I am not able to understand why it is needed, since drop_cache is a non-destructive operation, and dirty data is not going to be deleted by drop_cache. I have also seen a behavior where echo 1 > /proc/sys/vm/drop_caches first commit dirty data back to disk and then frees the cache. This is seen through /proc/meminfo "Dirty" & "Writeback".

  • 1
    "I have read a lot of docs saying ..." Could you link to such a doc?
    – Mat
    Jul 6, 2013 at 10:59
  • 2
    Sure, Linux Kernel Documentation about "vm" subsystem kernel.org/doc/Documentation/sysctl/vm.txt Excerpt - drop_caches 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. Jul 8, 2013 at 5:54

1 Answer 1


Anyways I got the answer on stackoverflow which I corroborated by doing a small experiment.

"sync" only makes dirty cache to clean cache. cache is still preserved. drop_caches doesn't touch dirty caches and only drops clean caches. So to make all memory free, it is necessary to do sync first before drop_caches in case flushing daemons hasn't written the changes to disk.

My blog about this little experiment -

What are exactly O_DIRECT, O_SYNC Flags, Buffers & Cached in Linux-Storage I/O?

Stackoverflow link -

“sync” before drop_caches,is it necessary?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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