cleancache: attempts to clear cache and buffers on linux
I've found this piece of code lingering around on my linux box.
It reads /proc/meminfo and according to those values it attemps to allocate and occupy some memory. After allocation and freeing those memory blocks, linux kernel flushes most of the file caches and buffers. I don't know why I've written this. Maybe to benchmark cold-start of some applications. There should be a clean kernel interface just to do this actually, hmm.
engin@engin-desktop:~$ gcc -o cleancache cleancache.c -ansi -pedantic -W -Wall
engin@engin-desktop:~$ ./cleancache
Trying to free buffer and cache...
Before -> MemFree: 175412k Cached: 23572k Buffers: 228156k Total: 427140k
100.00%
After -> MemFree: 430400k Cached: 5968k Buffers: 26272k
[View|Download] Code