There is no portable way. You can prevent replacing pages with mlockor mlockall(but this requires sufficient permissions), or you can use a non-portable method. On Linux, the file kpageflagsin /procwith the file pagemapin the process directory in /procshould be sufficient to provide you with information. They are documented in the Linux source Documentation.
source
share