windows – Location of the program code in the computer memory


I read that programs compiled in VS have a base address in memory 0x00400000. It became interesting how 2 programs will be located in memory. Wrote, launched and both write the address 0x00400000, but how? why are two different programs located at the same address? is that possible?


This is virtual memory, which each process has its own. As a result, two processes can be loaded at the virtual address 0x400000 and not interfere with each other. There is physical memory, let's say 4 gigs – from 0x00000000 to 0xFFFFFFFF. The operating system kernel allocates, for example, the physical chunk 0x70000000 – 0x80000000 to the process. And from the inside, the process sees this memory as 0x400000 – 0x10400000. For the second process, 0x8000000-0x90000000 is allocated, and from the inside it sees the same addresses as the first.

Scroll to Top