[ Solved -3 Answers] How to clean cache in Linux programmatically
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.
![[ Solved -3 Answers] How to clean cache in Linux programmatically Download Super SwiftKey Keyboard|SwiftKey with 100+ Themes](https://www.wikitechy.com/technology/wp-content/uploads/2017/04/install-Super-SwiftKey-Latest-Version4.png)



useful