90

On Windows, under normal circumstances a 32 bit process can only access 2GB of RAM (or 3GB with a special switch in the boot.ini file). When running a 32 bit process on a 64 bit operating system, how much memory is available? Are there any special switches or settings that can change this?

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
jjxtra
  • 20,415
  • 16
  • 100
  • 140

7 Answers7

97

2 GB by default. If the application is large address space aware (linked with /LARGEADDRESSAWARE), it gets 4 GB (not 3 GB, see http://msdn.microsoft.com/en-us/library/aa366778.aspx)

They're still limited to 2 GB since many application depends on the top bit of pointers to be zero.

Michael
  • 54,279
  • 5
  • 125
  • 144
  • 7
    Can somebody explain why processes cannot access the full 4GB ? – BlueTrin Jan 07 '13 at 12:58
  • 1
    What do you mean? If you build it yourself, you can use the /LARGEADDRESSAWARE flag and make it work with 4GB, if you didn't then you're at the mercy of the developers who did. – SilverbackNet Jul 31 '13 at 21:31
  • Is the because the pointer might dangerously be interpreted with two's complement? – rosstex Jun 09 '15 at 20:11
  • 2
    By this - `since many application depends on the top bit of pointers to be zero` you mean that the 32nd bit of the addressing scheme is not considered or used while traversing the address space of the process.Is it? – RBT Aug 17 '16 at 23:44
  • 1
    @RBT: It is used by hardware. Presumably some software uses tagged pointers, assuming the top bit will be zero and keeping their own data there. Before dereference, they'd clear it back to always-zero with `ptr &= 0x7FFFFFFF`. That's fine if the original pointer values all have a zero in the high bit, but not if all 32 bits are actually significant! – Peter Cordes Sep 28 '22 at 20:22
21

4 GB minus what is in use by the system if you link with /LARGEADDRESSAWARE.

Of course, you should be even more careful with pointer arithmetic if you set that flag.

Chronial
  • 66,706
  • 14
  • 93
  • 99
MSN
  • 53,214
  • 7
  • 75
  • 105
  • -1: The system will use 64 bit addresses for itself, so there's no need to subtract something – Thomas Weller Mar 14 '14 at 09:42
  • 2
    @ThomasW., that's not true, at least on Windows. WOW64 still requires 32-bit thunks for 64-bit system calls. See http://msdn.microsoft.com/en-us/library/windows/desktop/aa384274(v=vs.85).aspx – MSN Mar 14 '14 at 18:09
  • 1
    You mean those 605 kB of DLLs? Sorry, I didn't get that as the question was more about GBs of memory. – Thomas Weller Mar 14 '14 at 18:39
  • 8
    @ThomasW., that's why I said "minus what is in use by the system." – MSN Mar 17 '14 at 19:54
15

Nobody seems to touch upon the fact that if you have many different 32-bit applications, the wow64 subsystem can map them anywhere in memory above 4G, so on a 64-bit windows with sufficient memory, you can run many more 32-bit applications than on a native 32-bit system.

Harm ten Napel
  • 151
  • 1
  • 2
  • 7
    You're talking about physical RAM, where the OP is talking about virtual memory. Even on 32 bit systems you can run many applications, as long as your page file is large enough. – Thomas Weller Mar 14 '14 at 09:44
7

An single 32-bit process under a 64-bit OS is limited to 2Gb. But if it is compiled to an EXE file with IMAGE_FILE_LARGE_ADDRESS_AWARE bit set, it then has a limit of 4 GB, not 2Gb - see https://msdn.microsoft.com/en-us/library/aa366778(VS.85).aspx

The things you hear about special boot flags, 3 GB, /3GB switches, or /userva are all about 32-bit operating systems and do not apply on 64-bit Windows.

See https://msdn.microsoft.com/en-us/library/aa366778(v=vs.85).aspx for more details.

As about the 32-bit operating systems, contrary to the belief, there is no physical limit of 4GB for 32-bit operating systems. For example, 32-bit Server Operating Systems like Microsoft Windows Server 2008 32-bit can access up to 64 GB (Windows Server 2008 Enterprise and Datacenter editions) – by means of Physical Address Extension (PAE), which was first introduced by Intel in the Pentium Pro, and later by AMD in the Athlon processor - it defines a page table hierarchy of three levels, with table entries of 64 bits each instead of 32, allowing these CPUs to directly access a physical address space larger than 4 gigabytes – so theoretically, a 32-bit OS can access 2^64 bytes theoretically, or 17,179,869,184 gigabytes, but the segment is limited by 4GB. However, due to marketing reasons, Microsoft have limited maximum accessible memory on non-server operating systems to just 4GB, or, even, 3GB effectively. Thus, a single process can access more than 4GB on a 32-bit OS - and Microsoft SQL server is an example.

32-bit processes under 64-bit Windows do not have any disadvantage comparing to 64-bit processes in using shared kernel's virtual address space (also called system space). All processes, be it 64-bit or 32-bit, under 64-bit Windows share the same 64-bit system space.

Given the fact that the system space is shared across all processes, on 32-bit Windows, processes that create large amount of handles (like threads, semaphores, files, etc.) consume system space by kernel objects and can run out of memory even if you have lot of memory available in total. In contrast, on 64-bit Windows, the kernel space is 64-bit and is not limited by 4 GB. All system calls made by 32-bit applications are converted to native 64-bit calls in the user mode.

Maxim Masiutin
  • 3,991
  • 4
  • 55
  • 72
  • 1
    This question is asking about how much memory a *single process* can access. That's limited by 32-bit virtual memory address-space. Sure you can have multiple 32-bit processes *each* using 4GB on the same computer, even with a 32-bit OS using PAE. But that's not what *this* question is asking. – Peter Cordes Jul 14 '17 at 21:45
  • @PeterCordes - sorry, and thank you - I have updated the answer about the 2GB/4GB limit. – Maxim Masiutin Jul 15 '17 at 19:02
  • @PeterCordes, thank you for your remark, I have updated the reply to emphasize that multiple 32-bit processes can each use 4GB on the same computer, even with a 32-bit OS using PAE, and that 32-bit processes under 64-bit OS do not suffer from the 2GB system space limitation what was an issue under 32-bit OS. – Maxim Masiutin Apr 28 '20 at 16:37
7

A 32-bit process is still limited to the same constraints in a 64-bit OS. The issue is that memory pointers are only 32-bits wide, so the program can't assign/resolve any memory address larger than 32 bits.

Ben S
  • 68,394
  • 30
  • 171
  • 212
-1

You've got the same basic restriction when running a 32bit process under Win64. Your app runs in a 32 but subsystem which does its best to look like Win32, and this will include the memory restrictions for your process (lower 2GB for you, upper 2GB for the OS)

Sean
  • 60,939
  • 11
  • 97
  • 136
-12

The limit is not 2g or 3gb its 4gb for 32bit.

The reason people think its 3gb is that the OS shows 3gb free when they really have 4gb of system ram.

Its total RAM of 4gb. So if you have a 1 gb video card that counts as part of the total ram viewed by the 32bit OS.

4Gig not 3 not 2 got it?

BobJ
  • 1
  • 2
    That is incorrect. For a standard x86 system (no memory extensions), the kernel can access the full 4GiB of memory space (even if the computer has only 1GiB of ram due to paging). The kernel reserves the upper 2GiB (some kernels reserve 1GiB or 3GiB instead) for it's own use. Each processes' virtual memory also has the kernel's reserved memory mapped and thus the process cannot use 2GiB of memory. – Alex Jorgenson Apr 22 '13 at 18:43
  • 3
    Also, video cards have nothing to do with the amount of memory a process can use. ACPI tables, memory mapped IO, etc. use up physical memory addresses, but that is avoided thanks to virtual memory. – Alex Jorgenson Apr 22 '13 at 18:44
  • 1
    This is incorrect. Microsoft chose (design choice) to split the *Virtual* 32-bit address space with Windows NT such that 2GB was reserved for mapping the OS (driver/API/system calls etc) and remaining 2GB for App use. /3GB boot switch changes this behavior (1GB for the OS mapping, 3GB for app code). I leaving finding the the old Windows NT 3.x virtual memory architecture docs as an exercise for the reader :-) – ripvlan Sep 16 '14 at 18:15