Dude, Where's My 4 Gigabytes of RAM?

Due to fallout from a recent computer catastrophe at work, I had the opportunity to salvage 2 GB of memory. I installed the memory in my work box, which brings it up to 4 gigabytes of RAM-- 4,096 megabytes in total. But that's not what I saw in System Information:


This is a companion discussion topic for the original blog entry at: http://www.codinghorror.com/blog/2007/03/dude-wheres-my-4-gigabytes-of-ram.html

Brandon Paddock wrote “To those claiming Linux doesn’t have this problem: You’re wrong. A 32-bit Linux OS will have the exact same limitations, right down the the kilobyte.”

But what about 64-bit Linux?

Jeff:
Your math is incorrect. In both calculations, you forget to convert from bits to bytes (8 bits = 1 byte). Also, you’re not considering memory paging. Without paging, x86 processors using a 32 bit address word can only access 0.5 GB of memory. See http://spreadsheets.google.com/ccc?key=pYK6MlUiNyheNUOvbGxggNQhl=en_US for the math. NOTE: Clicking the sheet names at the bottom displays different calculation sets.

FWIW, I completely agree with Ian (and others) when he says that the issue isn’t quite as facile as Jeff’s thesis makes it seem. Look at Mac OS X: it’s (now) a 64bit kernal, but the maximum amount of RAM a MacBookPro will take is 4GB, while a MacBook will only handle 3GB. The MacPros, however, handle up to 16GB of RAM. Different chip set, same OS = different specs. Apple simply didn’t include the extra hardware to allow higher memory configurations.

Jae:
x86 is a processor architecture. ‘Nbit’ (where N is 16, 32, 64, etc) refers to the word size a processor operates on. x86 processors began with 16bit word sizes, moved to 32 and are moving to 64.

One (very inexact) way to think about it is to say that CPUs are like internal combustion engines. They may differ in how the bits fit together, how many bits there are or even how quickly they do their jobs. But, basically, they’re all pretty much alike: fuel comes in, combustion happens, piston moves, and wheels turn.

Word size can be likened to the amount of pistons an engine has; more pistons means more fuel is combusted (work is done) every cycle. Also, relevant to the above discussion, larger word size means more physical address lines are available (32 more, in this case). See above link for the math behind this.

That link should’ve been: http://spreadsheets.google.com/ccc?key=pYK6MlUiNyheNUOvbGxggNQhl=en_US

If your hardware is physically capable of addressing more than 4gb of RAM (this can be limited in the chipset), then you can access up to 64 gigs of RAM with Linux in 32-bit mode. Using PAE, which is invisible to applications, you just don’t have to worry about system memory; if you’ve got it, you can use it.

However, I think there’s still a 2gb limit per process, 3 if you use a special boot parameter to the kernel. You can run a lot of 2gb processes, but can’t run a single 32-gig program, as far as I know.

If, of course, you have a 64-bit CPU, you can use as much RAM as you like. Programs can easily use all the RAM too, but they do have to be recompiled for 64-bit. 32-bit compiles are still limited to 2 or 3 gigs.

Linux is a pretty damn good solution, overall, but the 32 to 64-bit transition is painful on all OSes. Linux runs 32-bit code quite nicely when the kernel is 64-bit, but you can’t use a 32-bit plugin, like Flash, with a 64-bit Firefox. You have to be aware of the differences and work around occasional problems.

It’ll probably be least visible on the Mac. They go to great pains to hide the 32- versus 64-bit problems.

Actually it is O/S issue http://www.microsoft.com/whdc/system/platform/server/PAE/PAEdrv.mspx

Shows that XP is limited to 4GB whereas Datacentre is limited to 128GB! Once you start dealing with kit in this range ($80K+) you want to have all your RAM available - (why do you want 16GB? well if you have a 20GB database and it gets hammered you want in RAM)

http://support.microsoft.com/kb/283037 describes what happens with /3gb and /pae

If you really want to see problems - check out “Desktop Heap” http://support.microsoft.com/kb/126962 http://support.microsoft.com/default.aspx?scid=kb;EN-US;184802

The desktop heap is set on 32-Bit systems to 48MB! That’s all, and on servers where processes can run as users, it’s a problem. The limit is about 90 users (each starting out with 512KB used) on a box as more than this (48/.5=96) starts to hit the usage by system/service accounts. see http://support.microsoft.com/kb/169321 on how windows can start a new process in a new windows desktop

Very good article. I work on BIOS for a living, and I have to give this explanation to testers all the time.

Which platforms are mote likely to support remapping over 4GB … servers. Most desktops and notebooks won’t support it.

If the memory controller will support remapping memory above 4GB, then you’re fine. The “memory hole” will get pushed up over 4GB. If not, then you lose that memory to all of the PCI devices on the system.

On AMD Athlon/Turion/Opteron platforms, the memory controller is in the CPU. On Intel platforms, this is the MCH/GMCH (also called a “northbridge”).

In any 32-bit operating system, the physical address space
is limited, by definition, to the size of a 32-bit value

No… the /virtual/ address space is limited to 32 bits. It’s possible to have more /physical/ memory than this, and it’s even useful if you want to run more than one large process at a time. PDP-11s did this, AFAIR.

I don’t know enough about Windows or Intel architecture processors to know whether this is possible in that environment, though.

Do you need 4gigs of ram on a desktop machine though?

Well a few years ago I would have laughed at you but seeing how 2gigs actually makes a difference in Vista due to the improved memory management, I’d have consider going for it… If it didn’t mean I had to scrap my 4* 512 stick… But I guess even that’s off the table until people stop faffing around with 32bit desktop applications and decide they’re bored of it.

John: you’re absolutely right. Corrected.

And the 36-bit PAE Intel extensions are what you’re thinking of, but they’re still a nasty hack. Far better to lace up your boots and go 64-bit now that AMD blazed the trail.

I’m getting confused with all these comments, eheh. Isn’t there a difference between physical memory and virtual memory? Can’t the x86 architecture handle enormous amounts of virtual memory?

What I’m being taught in college is that certain memory addresses are reserved for ROM memory and I/O devices. And since the physical limit is 4GB, if you have addresses that are fixed to other devices than what we know as the RAM memory, then you won’t use all those 4GB because a portion of those 4gb is not even addressable.

That’s what I understand, anyway. But then I heard that there is virtual memory, but that’s where those pagefiles come into play, I guess. I still don’t understand it very well :stuck_out_tongue:

When I built up my current PC I chose “Windows XP x64 Pro” for this very reason (plus I didn’t see the point in restricting my shiny new 64-bit CPU).

Sadly support for XP x64 has been mediocre at best. Some major hardware players (e.g. Netgear) have outright refused to produce drivers for it. Others have produced cut-down software that functions, but misses important features when compared to the 32-bit version.

Even Microsoft, who marketed x64 as meeting the “increasingly sophisticated demands for making home movies, working with digital photographs, using digital media” have not issued x64-compatible versions of their “Color Control Applet” or the “RAW Thumbnail Viewer” - both of which would be very useful add-ons for people working in exactly those fields.

Given this experience I am watching Vista 64-bit with quiet interest. A quick trawl around various hardware websites shows that most drivers offered are labelled as Vista 32-bit only. Is history set to repeat itself?

“It’s the final solution, at least for the lifetime of everyone reading this blog post today.”

You really want to say something like that? I remember getting a 16k expansion for my Apple II+ (cost $200 and brought me to 64k). I would bet that 64bit isn’t enough to last the next 40 years, probably not the next 20.

Graham, I expect the driver situation to be much better with Vista x64. The 64-bit version of XP release was a weird, out-of-band release that never had proper levels of support. XP was released in 2001, and x64 XP was released in, what, 2005? That’s weird.

But with Vista, x64 is a first-class citizen, released at the same time alongside all its x86 brethren.

Of course it’ll still take time. Some companies still don’t have plain old x86 drivers for Vista that are any good. But within the next 2 years, I expect x64 driver support to at rough parity with x86.

Nope.
Because you are obviously talking powers of two, the progression is gibi, tebi, pebi, exbi.
(http://en.wikipedia.org/wiki/Binary_prefix#IEC_standard_prefixes)

I’m a little disappointed with my recent install of Windows Vista (32bit). I have three gigs of ram (2x1GB 2x512mb) but BIOS and Vista only recognizes 2GB (the 2x1GB sticks). When I run applications like CPU-Z in Windows, it recognizes all four sticks. This isn’t the same issue but kind of related. Wondering if anyone had any idea what was going on? I was thinking the sticks were just not compatible but I’m not positive.

“Suffice it to say that we won’t be running out of physical or virtual address space on 64-bit operating systems for the forseeable future. It’s the final solution, at least for the lifetime of everyone reading this blog post today”

Eh? I remember when the Mac II came out, the article in MacWorld being amazed at the vast 4 gigabyte address range addressible by its 32 bit processor and proclaiming that we’d never hit that limit. Not to mention the old (if apocryphal) 640k-should-be-enough-for-anyone chestnut. You’re falling into the same trap.

Starting with 4GB, and assuming Moore’s Law holds constant, we hit 8192GB in 16 and a half years. I’m 27 now, and I damn sure intend to still be alive when I’m 44.

Julius:
“Isn’t there a difference between physical memory and virtual memory? Can’t the x86 architecture handle enormous amounts of virtual memory?”

Yes and yes (depending on your definition of enormous, I suppose).

Physical memory is just that, the ‘sticks’ you physically plug into slots inside your computer. Virtual memory, in a nutshell, refers to the method of an OS presenting non-contiguous memory as if it were contiguous. It’s an abstraction layer. Often times this means that some of the non-contiguous memory is actually a file on the hard disk, ‘swapped’ into and out of RAM as it’s needed.

“What I’m being taught in college…”

Sounds like they’re telling you the truth. During boot-time, some peripherals are assigned memory locations that the CPU reads from/writes to. This happens dynamically now (Plug-And-Play) but in the past, folks used to have to set the memory address themselves via DIP switches. That sucked. Reassigning these memory locations during runtime isn’t normally done (never, as far as I know).

“But then I heard that there is virtual memory, but that’s where those pagefiles come into play, I guess.”

Pages (pagefiles) may be files on disk or regions of memory or even something else (Vista lets users plug in a USB thumb drive to increase system memory). They don’t have to be files on disk.

See http://en.wikipedia.org/wiki/Virtual_memory for more info.
See my above link for some background math.

You say [quote]“To be perfectly clear, this isn’t a Windows problem-- it’s an x86 hardware problem. The memory hole is quite literally invisible to the CPU, no matter what 32-bit operating system you choose. The following diagram from Intel illustrates just where the memory hole is: image”[/quote]

and then show an image of a DOS compatible memory layout. As far as i’m aware, the only OS to actually use this kind of layout would be from a certain company in Redmond. I know none of my machines have a DOS compatibility region in place, so i would say this in fact is a windows issue, not and x86 one.

Kris

Jeff, I do hope things will improve, but I won’t be convinced that 64-bit has hit mainstream until I see major OEMs shipping PCs with Vista 64 installed as standard.

Personally I wish Microsoft had only released a 64-bit version. After all, it is supposed to be the OS for the next generation of PCs isn’t it? And I doubt many of them will be 32-bit.

Paul Thurrott makes some important points on his Windows SuperSite:
http://www.winsupersite.com/showcase/winvista_ff_x64.asp