I am running few benchmarks test using binaries made out of C. Is there anyway so I can ask kernel not to cache any part of these binary programs?


Have a look at the kernel documentation on "drop_caches".


Here's a small section:-

Writing to this will cause the kernel to drop clean caches, as well as
reclaimable slab objects like dentries and inodes.  Once dropped, their
memory becomes free.

To free pagecache:
    echo 1 > /proc/sys/vm/drop_caches
To free reclaimable slab objects (includes dentries and inodes):
    echo 2 > /proc/sys/vm/drop_caches
To free slab objects and pagecache:
    echo 3 > /proc/sys/vm/drop_caches

This is a non-destructive operation and will not free any dirty objects.
To increase the number of objects freed by this operation, the user may run
`sync' prior to writing to /proc/sys/vm/drop_caches.  This will minimize the
number of dirty objects on the system and create more candidates to be
| improve this answer | |
  • I tried this free && sync && echo 3 > /proc/sys/vm/drop_caches && free from a similar answer, It didnt clear all cache but most of it – Edward Torvalds Nov 16 '15 at 20:14

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.