I got the idea when thinking of arrays.
For example, when you want to expand the array, you could allocate a new snippet of memory and assign it the virtual address just beyond the range of the first array. The new snippet of memory would of course get a new virtual address, in which I thought, how about mirroring the virtual address?
Of course, I could just mirror a virtual address to the same physical memory too.
Which makes me wonder... even if you allocate, say, 100 bytes of memory which is placed contigous in virtual memory, will it also gaurantee to be placed contigous in physical memory?
Code:
char* my_array = new char[100];
// Code goes here
// ...
my_array[99] = 'H';
// End of array, need to expand.
char* my_array2 = new char[100];
my_array[100] = 'e'; // my_array + 100 should be pointing to my_array2[0] here.