1822732 Members
3742 Online
109644 Solutions
New Discussion

Problem with mallopt()

 
Sunil Hegde_1
New Member

Problem with mallopt()

Hi,

the call int mallopt(int cmd, int value); in malloc.h it defines a cmd M_ENABLE_MMAP, plz can any body tell me what it means and why it is used?? is documentation/help available on it any where??

Thanks
Sunil.
1 REPLY 1
Mike Stroyan
Honored Contributor

Re: Problem with mallopt()

It tells malloc to switch from brk calls to mmap of shared memory segments when brk calls stop working. That lets a 32-bit process malloc more memory than it could with brk alone. It was not officially documented. It is not a good general solution because it uses up the system-wide shared memory address space. Even two processes using M_ENABLE_MMAP could interfere with eachother. Many processes using it would very quickly reach the point where they couldn't get substantially more memory. And that would also interfere with the allocation of shared memory for interprocess communication.
Current PA-RISC HP-UX releases have better solutions. Use "ld -N", chatr +q3p, and chatr +q4p for 32-bit processes. Or use 64-bit processes.