Mmap, c programming

Daryl Tester Daryl.Tester at iocane.com.au
Wed Jun 22 11:03:07 CST 2005


Nigel Rochford wrote:

> However, the function crashes and gives out the message ENOMEM
> after mapping about 2.6GB.

"Crashes"?  It wouldn't be reporting ENOMEM if it crashed.

Bevan Coleman wrote:

> So each process can has it's own 4GB address space... almost.. :(

Other factors that contribute to "memory loss" are the process
itself, any shared libraries (which are also mmap'd), the heap
and stack.  Any of these can punch holes in the memory of what
mmap can map contiguously.  I'm not so familiar with Linux's
method, but I know that depending on what HP-UX allocates it
picks on different quadrants, which are all 1 GB in size (for
32 bit processes).

Poking around /proc/PID/maps will give you a good idea of what
memory is available for allocating.


-- 
Regards,
  Daryl Tester,  Software Wrangler and Bit Herder, IOCANE Pty. Ltd.

"Security is like an onion; if I cut one up and jam it in your eye
 you'll know all about it." -- Conversations with Colleagues.



More information about the linuxsa mailing list