4
votes

I am running a program with certain array variable. I am taking translating the virtual address(VA) of this array into physical address(PA) using /proc/self/pagemap file which is supported in Linux systems(ubuntu). I tried to observe the VA-PA mapping by running the same program several times (with a gap in time between successive runs). What I have observed is the PA remains the same in all the runs.

It is reasonable if VA remains same, but why PA also remains the same.? PA depends on the free pages available in the RAM which is maintained by the OS. It has to vary wrt to the system load at that moment. Considering all this I am expecting the PA to be varrying but, the opposite is what I observed.

What concept I am missing of OS/Architecture that answers this question?

1
have you tried starting some other programs and checking if you get the same? If you always have the same memory layout there should not be a need to use a different physical adress space (depending on the OS implementation though) the size of your program can also influence where it is put. maybe when it is small enough you occupy a space no other general tool can. - Hayt

1 Answers

3
votes

"with a gap in time"

OS's expect applications to want to restart - so if the memory isn't running short, while the memory will be 'free' it will also have the binary cached just in case it's run again. Windows Task manager reports this reasonably well.

Time alone isn't enough to free this cache, and starting a couple of other applications also probably won't be enough; you need to start a number of unique processes (or just one that uses a lot of memory) to have it clear the cache.

Alternatively, as pointed out by acornagl, one can manually clear the cache by following the instructions posted here