4

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?

Marcus Müller
  • 34,677
  • 4
  • 53
  • 94
ANTHONY
  • 333
  • 5
  • 18
  • 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 Oct 21 '16 at 11:33

1 Answers1

3

"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

Community
  • 1
  • 1
UKMonkey
  • 6,941
  • 3
  • 21
  • 30
  • 1
    In addition to the answer I suggest: [How to clear the cache in Linux systems](http://unix.stackexchange.com/questions/87908/how-do-you-empty-the-buffers-and-cache-on-a-linux-system) – acornagl Oct 21 '16 at 11:39
  • Great answer. I would however point that it is customary to attribute the contributions from the comments. E.g. "As pointed by @acornagl you can manually clear the cache by..." – bolov Oct 21 '16 at 11:56
  • @bolov thank you, I will do it starting from next time ;) – acornagl Oct 21 '16 at 12:00