Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

On Linux, how do you determine which individual pages are resident?

Tags:

linux

memory

How can one determine which individual pages are resident (i.e., committed in RAM)? On Linux, /proc/pid/smaps gives, for a fixed set of ranges, how many bytes are resident in that range, but this information doesn't tell you what actual ranges of memory are resident.

As for what this is intended to be used for: I already have data associating allocation ranges with the source line info. This is useful for finding who is allocating how much. Given resident memory ranges, I could correlate the data to find who is allocating how much memory that was being kept resident.

Thanks!

like image 881
Luke Avatar asked Sep 27 '11 17:09

Luke


1 Answers

There is a syscall to do this:

mincore - determine whether pages are resident in memory

int mincore(void *addr, size_t length, unsigned char *vec);
like image 77
derobert Avatar answered Oct 10 '22 18:10

derobert