Command to flush file system cache to prepare for performance testing?

Sam Tygier samtygier at
Tue Dec 9 23:23:58 UTC 2008

Martin Olsson wrote:
> Hi,
> If grep through all files in a directory twice, then the first time takes
> a lot longer because the second run will have most of the files available
> in the "in memory file system cache".
> I want to do some basic performance testing for a scenario involving disk I/O.
> I'm wondering if there is a command to purge the file system cache, either
> for a specific directory or file (which would be great) or otherwise purge the
> whole thing.
> Basically, to create repeatable perf tests and get consistent results I would
> like to pin down all the "system state" so that any changes in numbers will
> be directly attributable to my code changes.
> Does anyone know such a command to flush the file system cache?
> 		Martin

i think this is what you are after
# echo 1 > /proc/sys/vm/drop_caches

see for more info/options

sam tygier

More information about the Ubuntu-devel-discuss mailing list