Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I usually run up a couple hundred tabs in my browser (Pale Moon x86), frequently pushing the program's memory use up to 2-3GB.

What happens when a program is running up against the memory limit? Does the system just keep feeding it memory, but "now" in the form of disk swapping? Does the program "know" that it's hit the system limit of memory?

It's only been recently that I've had the flash of (simplistic) insight as to why the browser doesn't keep growing in memory size beyond there, and starts to chug with awful performance -- 32/64 bit memory space!

So I've now begun turning to Waterfox, an x64 variant. Will an x64 program just continue growing in the amount of its memory use, up until the system says "no more"?

share|improve this question
    
If the program is "smart" it avoids (to the extent possible) hitting the memory limit, or "manages" the error messages it gets when the limit is exceeded. If the program is not "smart" it crashes. But using 2-3G in any application is going to stress most systems, especially if you installed RAM is less than about 6G. –  Daniel R Hicks Jun 27 '12 at 15:49

3 Answers 3

up vote 6 down vote accepted

What happens when a 32 bit program (running on an 64 bit machine) hits the memory limit?

The same thing that happens on a 32-bit system: the program fails in some way.

As far as the 32-bit program is concerned, the "universe" consists of up to 4GB of data. It does not know about the greater area outside of its own little box (think of the fish analogy that Michio Kaku uses in his book Hyperspace).

If you open too many tabs and drive its memory usage up, it will fill up the universe and when it runs out, it will complain that it does not have enough memory to open a new tab or display a picture or whatever. Well, it will complain if it is well written; if it is poorly written, then it will just crash.

Think about it from a low-level, programming point-of-view. The 32-bit program uses 32-bit pointers to store is data. That means it can point to at most 4GB of data. If it has already used up 4GB, then even if the OS can give it more, what would be the value of the new pointer? The new address would be too far away and the program would not be able to put such a large address in a 32-bit pointer.

As an analogy, think of phone numbers. Let's say in your city, there are not too many people, so your phone numbers are all 5-digits long allowing for up to 10,000 numbers, so all you address books have up to 10,000 spaces for phone numbers. The country however has lots of people, so it uses 7-digit numbers. Even though the country can give you the number of a person far away, you would not be able to store it in your address-book because you only have 5-digits of space to print numbers in, so once you have printed 10,000 numbers, the book is completely full.

share|improve this answer
    
Very well put. Thanks! –  Coldblackice Jun 28 '12 at 9:40

A 32-bit application only has a 32-bit address space, even on a 64-bit system, so there's no way it can use more than 4 GB of virtual memory (and likely significantly less than that). A 64-bit application has a much larger address space, and thus can use more virtual memory. But there's only so much RAM and when it's full, data goes to the page file, which slows the whole system down (often dramatically).

share|improve this answer

When a 32-bit program begins to approach the virtual memory (address space) limit, its memory allocations will begin to fail. Every memory allocation the process makes require sufficient available, contiguous address space in the process' virtual memory space, and for a 32-bit process, that's 4GB. On Windows 7, the 2GB and 3GB limits don't apply to 32-bit programs on a 64-bit operating system, if they're large address aware. (Which every significant modern program should be.)

What the process does when its memory allocations fail is up to it. Typically, the program will try to squeeze its use of memory by throwing away anything it doesn't need, unmapping files it wasn't using, and so on. But ultimately, it will simply have to refuse to do things.

Some programs do implement forms of paging where they write structures out to a file to read them back later. They will stay in RAM the whole time, but this will still be slower because of the need to juggle the mappings around.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.