简体   繁体   中英

Why the physical address is same across the runs?

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?

"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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM