heap limits: mmap(2) vs. break(2) on i386
Tijl Coosemans
tijl at coosemans.org
Sat Nov 28 13:09:09 UTC 2009
On Friday 27 November 2009 22:17:31 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. Here is my limits:
>
> Resource limits (current):
> cputime infinity secs
> filesize infinity kB
> datasize 2097152 kB
> stacksize 65536 kB
> coredumpsize infinity kB
> memoryuse infinity kB
> memorylocked infinity kB
> maxprocesses 5547
> openfiles 20000
> sbsize infinity bytes
> vmemoryuse infinity kB
>
> Running ktrace I see:
>
> 9154 java CALL mmap(0,0x44000000,PROT_READ|PROT_WRITE|PROT_EXEC,MAP_PRIVATE|MAP_NORESERVE|MAP_ANON,0xffffffff,0,0)
> 9154 java RET mmap -1 errno 12 Cannot allocate memory
> 9154 java CALL write(0x1,0xbf9fe378,0x2b)
> 9154 java GIO fd 1 wrote 43 bytes
> "Error occurred during initialization of VM
On i386 a process has only 3GiB of address space. If you reserve 2GiB
for datasize (sbrk), there's less than 1GiB available for mmap. Unless
you have a program that still uses sbrk and needs 2GiB you should make
maxdsiz much smaller. Since FreeBSD 7 malloc can use mmap besides sbrk
so you can set maxdsiz to a really small value if you want to.
More information about the freebsd-stable
mailing list