File Read Cache - How to purge?

Nick Craig-Wood nick at craig-wood.com
Tue Aug 21 12:30:08 EDT 2007


Hrvoje Niksic <hniksic at xemacs.org> wrote:
>  Signal <mugi at pinesalad.net> writes:
> 
> > 2. Is there anyway to somehow to take advantage of this "caching" by
> > initializing it without reading through the entire file first?
> >
> > 3. If the answer to #2 is No, then is there a way to purge this
> > "cache" in order to get a more accurate result in my routine?  That
> > is without having to read another large file first?
> 
>  On a Unix system the standard way to purge the cache is to unmount the
>  file system and remount it.

If you are running linux > 2.6.18 then you can use
/proc/sys/vm/drop_caches for exactly that purpose.

  http://www.linuxinsight.com/proc_sys_vm_drop_caches.html

Eg

# free
             total       used       free     shared    buffers     cached
Mem:       1036396     954404      81992          0      33536     347384
# echo 1 > /proc/sys/vm/drop_caches
# free
             total       used       free     shared    buffers     cached
Mem:       1036396     658604     377792          0        348      91240
# echo 2 > /proc/sys/vm/drop_caches
# free
             total       used       free     shared    buffers     cached
Mem:       1036396     587296     449100          0        392      91284
# echo 3 > /proc/sys/vm/drop_caches
# free
             total       used       free     shared    buffers     cached
Mem:       1036396     588228     448168          0        692      91808

-- 
Nick Craig-Wood <nick at craig-wood.com> -- http://www.craig-wood.com/nick



More information about the Python-list mailing list