1

If one has a 32 bit machine, a single program cannot address more than 2^32 bytes, or 4 GB. Would making use of mmap() allow one to exceed the 4 GB limit?

5
  • 2
    mmap() would allow you to implement Virtual Memory Commented May 11, 2015 at 23:12
  • Right...but could you help me understand how that would help me find the answer? Correct me if I'm wrong, but isn't it implicit that this question is on virtual memory? All programs and OSes use virtual memory these days, right?
    – Tosh
    Commented May 11, 2015 at 23:40
  • The answer to the question you asked is yes. Did you have a more specific question you wanted to ask? Commented May 11, 2015 at 23:44
  • Thanks for the answer. But I'm still confused as to why you mentioned "Virtual Memory". Isn't the 4 GB I mentioned virtual memory as well? From what I understand the OS would be responsible for mapping the virtual memory (seen by the program) to RAM or swap.
    – Tosh
    Commented May 11, 2015 at 23:50
  • Time to buy a 64 bits processor & machine. Commented May 12, 2015 at 8:18

1 Answer 1

3

No, you can never exceed 4GiB of simultaneously addressable memory for a 32-bit binary. Usually, the kernel takes half and you are left with 2GiB user. Some kernels support a compromise split of 1GiB/3GiB.

However, you can ask the OS to map different portions of a file into memory at different times, essentially performing time multiplexing of the available address space. IMHO, at that point you might as well not memory map anything and just read() from the file into buffers.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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