Linux buffer cache state

Following Faidon’s comment on an earlier post, I came across  this informative site concerning Linux’s buffer cache state. In a nutshell, the following code will release all the cached data of a specified file.

#define _XOPEN_SOURCE 600
#include <unistd.h>
#include <fcntl.h>
int main(int argc, char *argv[]) {
    int fd;
    fd = open(argv[1], O_RDONLY);
    posix_fadvise(fd, 0,0,POSIX_FADV_DONTNEED);
    return 0;

There are some useful samples and examples on the mentioned web page. posix_fadvise description here.


One thought on “Linux buffer cache state

  1. Pingback: Twitter Trackbacks for Linux buffer cache state « : | : vortex of false deceit : | : [] on

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s