I saw that on a 64 bit windows OS the user virtual address space available is 8 terra bytes. But if the program we are executing on this is running in 32 bit compatibility mode is this much of user space still available ? or does it behave like a normal 32 bit OS and gives only 2GB user address space?
Your process will only see a 4GB virtual address space when it is running as a 32 bit process. It will not be able to addresses anything higher.
If your program is running as a 32 bit process on the Wow64 subsystem, it will see the exact same address space that it would see on an actual 32 bit OS. With no special options, a 32 bit process will have 2GB of memory available.
The only difference is the avaliable memory if you use the LargeAddressAware option. In a normal 32 bit process this allows for 3GB of addressable memory. In a Wow64 process it can see up to 4GB (Source)
My original answer was pretty bad. Here is a link that explains what JaredPar was saying pretty well.
Microsoft has a chart showing the various limits: Memory Limits for Windows Releases
To summarize just the user-mode virtual address space:
- 32-bit Windows:
- 32-bit process: 2 GB by default; 3 GB with
/LARGEADDRESSAWARE:YES
and 4GT
- 32-bit process: 2 GB by default; 3 GB with
- 64-bit Windows (x64 architecture):
- 32-bit process: 2 GB by default; 4 GB with
/LARGEADDRESSAWARE:YES
- 64-bit process: 8 TB by default; 2 GB with
/LARGEADDRESSAWARE:NO
- 32-bit process: 2 GB by default; 4 GB with
4GT is 4-gigabyte tuning:
- XP:
/3GB
boot.ini switch - Vista:
bcdedit /set increaseuserva 3072
Mark Russinovich made a blog post explaining many these limits: Pushing the Limits of Windows: Virtual Memory
As far as the hardware is concerned, when you're running in compatibility mode (i.e. IA32_EFER.LMA is set and the L bit is clear in CS's segment descriptor) the segments behave like 32-bit segments. That is:
- the segment base is limited to 32 bits.
- the segment limit is limited to 32 bits as well (using the G bit).
This effectively limits you to 4GB of virtual addresses. I'm not familiar with how the OS partitions virtual memory in the various modes, but this is the hardware limit. (sorry... I'm a hardware guy, not an OS expert)