我正在运行一些基于C语言编译的二进制文件进行基准测试。有没有办法让内核不缓存这些二进制程序的任何部分?
https://www.kernel.org/doc/Documentation/sysctl/vm.txt
这是一个小节: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
dropped.
free && sync && echo 3 > /proc/sys/vm/drop_caches && free
,来自一个类似的回答。它没有清除所有缓存,但是清除了大部分。 - Alex Jones