MacOS – Why can Mac OS X 32-bit access all 4GB of memory, while Windows 32-bit can’t

macosmemorywindows

I don't understand why Mac OS X 32-bit kernel can access all 4GB of memory (and even more) while Windows 32-bit can only work with ~ 3,3 GB, and for using more than 4GB you need 64-bit Windows. Even when 32-bit Windows runs on Mac hardware with > 4GB mem, it still doesn't use it all. Sorry for talking about Windows on this site :-), I would just like to understand the difference.

Best Answer

Recommended reading: Road to Mac OS X Snow Leopard: 64-bits, Santa Rosa, and more (and the rest of Prince McLean's Road to Snow Leopard series). If you don't want that much reading, I'll summarize:

First, you have to realize that OS X doesn't have a single 32/64-bit mode switch like Windows does; It'll happily run 64-bit apps under a 32-bit kernel, or vice versa, and both of those are independent of what the physical memory subsystem can support. Mind you, the bitness of apps and kernel do impose memory limits: an app running in 32-bit mode can only address 4GB of virtual memory no matter how much is installed/supported in the machine (although a Mac with lots of RAM can run several fully-resident 4GB processes at once); and if the kernel is in 32-bit mode it can only allocate up to 4GB for its various data structures (page table, process table, open file table, etc). This is already a bit different from the way Windows does it, as it shares address space between the kernel and the running process, so they each only get 2GB. The advantage of the Windows method is that it doesn't require a cache flush to switch in and out of the kernel, making it faster. But OS X only needs to flush the cache if both the program and kernel are in 32-bit mode; if either is 64-bit, they share space and avoid the speed penalty.

Now, on to the question you're asking about: physical RAM limits. Many early Intel Macs actually have the same ~3GB memory limit that 32-bit Windows has, for the same reason: some of the 4GB physical address space is taken up by memory mapped I/O, especially the video card. Some later Macs used the Santa Rosa support chipset, which allowed them to put the I/O in a separate address space, and use up to 4GB of physical RAM. Higher-end (/even newer) Macs have PAE, which allows much more physical RAM. Rumor is that Windows doesn't support PAE in most of their 32-bit OSes because of driver compatibility problems. Apple controls most of the relevant drivers anyway, so they made it work; if the hardware supports it, the OS just uses it.