We write a benchmark tool in C++ where we want to clear the filesystem memory cache between experiments.
My question is how can we do this programmatically directly within C++?
Try this :
[ad type=”banner”]Try this sample code:
[ad type=”banner”]Clean page cache in linux programmatically
- You are probably stuck with opening the file /proc/sys/vm/drop_caches, writing 1 to it and close it again. There is no dedicated syscall for that operation.
Depending on what you try to achieve, the (optional) preceding sync() can help free some more memory.
useful