Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 28 Nov 2009 13:38:50 +0100
From:      Tijl Coosemans <tijl@coosemans.org>
To:        Maxim Sobolev <sobomax@sippysoft.com>
Cc:        FreeBSD Hackers <freebsd-hackers@freebsd.org>, stable@freebsd.org, freebsd-current@freebsd.org
Subject:   Re: heap limits: mmap(2) vs. break(2) on i386
Message-ID:  <200911281338.53430.tijl@coosemans.org>
In-Reply-To: <4B1041EB.9020109@sippysoft.com>
References:  <4B1041EB.9020109@sippysoft.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200911281338.53430.tijl>