views:

1019

answers:

5

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?

A: 

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.

RussellH
On windows, a 32 bit process can only access 2GB of memory.
JaredPar
I guess "see" was maybe the wrong word. My understanding was that above 2GB was reserved for the kernel, but was still part of the virtual address space for the process, and 2 GB were available for user allocations.
RussellH
A: 

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)

JaredPar
/LARGEADDRESSAWARE:YES gives you 4 GB of virtual address space under WoW64, not 3 GB.
bk1e
@bk1e, I wasn't aware of that. It took me a bit of googling but I was able to confirm that and updated my post. I find that a very odd change but interesting.
JaredPar
A: 

My original answer was pretty bad. Here is a link that explains what JaredPar was saying pretty well.

http://msdn.microsoft.com/en-us/library/ms189334.aspx

RussellH
+3  A: 

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
  • 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

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

bk1e
Important to note that depending on the executables being created, you may have to use *editbin* to set the LARGEADDRESSAWARE flag on the PE executable, itself, to take advantage of the extra address space.
Michael
A: 

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)

Nathan Fellman