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?

  • 2
    mmap() would allow you to implement Virtual Memory – Robert Harvey May 11 '15 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 May 11 '15 at 23:40
  • The answer to the question you asked is yes. Did you have a more specific question you wanted to ask? – Robert Harvey May 11 '15 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 May 11 '15 at 23:50
  • Time to buy a 64 bits processor & machine. – Basile Starynkevitch May 12 '15 at 8:18

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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