heap limits: mmap(2) vs. break(2) on i386

Maxim Sobolev sobomax at sippysoft.com
Sat Nov 28 00:02:18 UTC 2009


Jason Evans wrote:
> Maxim Sobolev wrote:
>> I am trying to figure out why java fails to start with 1024MB of heap 
>> on i386 with 4GB of RAM and 4GB of swap. Both MAXDSIZ and DFLDSIZ are 
>> set to 2GB.
> 
> Some memory (1GiB?) is reserved for kernel address space, and you 
> reserved 2GiB for DSS.  That leaves less than 1GiB available after 
> shared libraries and whatnot are mapped.  If there is more than 1GiB 
> available, mmap can still fail due to the memory being non-contiguous.

Jason,

So, are you saying that by allocating 2GB to MAXDSIZ, I limit myself 
less than 1GB left to be allocated via mmap()?

Perhaps the cause of the problem is my interpretation of MAXDSIZ as an 
overall limit of VM that the process will be able to allocate regardless 
of the memory management interface is wrong, and in fact the process can 
allocate up to MAXDSIZ using sbrk(2) and then some extra using mmap(2) 
up to 3GB?

I tried lowering DFLDSIZ to 1.5GB, and it helped with Java. What is the 
best strategy if I want to maximize amount of memory available to 
applications? Most of modern applications use mmap(), isn't it? Then 
where MAXDSIZ can bite me if I set it to say 512MB?

-Maxim


More information about the freebsd-hackers mailing list