Skip to content

Instantly share code, notes, and snippets.

@glennklockwood
Created July 22, 2016 03:28
Show Gist options
  • Save glennklockwood/3dd935b004c311587697af58db84d66d to your computer and use it in GitHub Desktop.
Save glennklockwood/3dd935b004c311587697af58db84d66d to your computer and use it in GitHub Desktop.
Drop a file from page cache
#define _XOPEN_SOURCE 600
#include <unistd.h>
#include <fcntl.h>
int main(int argc, char *argv[]) {
int fd;
fd = open(argv[1], O_RDONLY);
fdatasync(fd);
posix_fadvise(fd, 0,0,POSIX_FADV_DONTNEED);
close(fd);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment