Using mincore()

The mincore() interface determines the residency of the memory pages in the address space covered by mappings in the specified range. Because the status of a page can change after mincore() checks the page but before mincore() returns the data, returned information can be outdated. Only locked pages are guaranteed to remain in the memory. For more information, see the mincore(2) man page.