windows – Location of program code in computer memory

Question:

I read that programs compiled on VS have a base address in memory of 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?

Answer:

This is virtual memory, which each process has its own. As a result, two processes can be loaded at 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, a physical chunk 0x70000000 – 0x80000000 for a 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