Heap size limit in java

Andrew Milton akm at theinternet.com.au
Fri Jun 18 16:14:03 GMT 2004

+-------[ Paul Dlug ]----------------------
| I originally posed to my question to freebsd-java. My issue was that I 
| was unable to set a java heap size of more than approx 2000m using java 
| (-Xmx2000m), it would fail with the error "COuld not reserve enough 
| space for object heap.
| Panagiotis Astithas looked into this a bit further and found that it 
| was due to the JVM being unable to mmap 3gb or more of memory. His 
| explanation is below along with some of the background information.
| Any help would be greatly appreciated. I imagine others have hit this 
| issue or will shortly. It's somewhat critical to getting large scale 
| java applications running on FreeBSD that the JVM be able to access 
| enough memory.

I think it's pretty well summed up in the mmap manpage (if this is still
currently correct).

     The len argument is limited to 2GB.  Mmapping slightly more than 2GB does
     not work, but it is possible to map a window of size (filesize % 2GB) for
     file sizes of slightly less than 2G, 4GB, 6GB and 8GB.

     The limit is imposed for a variety of reasons.  Most of them have to do
     with FreeBSD not wanting to use 64 bit offsets in the VM system due to
     the extreme performance penalty.  So FreeBSD uses 32bit page indexes and
     this gives FreeBSD a maximum of 8TB filesizes.  It is actually bugs in
     the file system code that causes the limit to be further restricted to
     1TB (loss of precision when doing blockno calculations).

     Another reason for the 2GB limit is that file system metadata can reside
     at negative offsets.

Totally Holistic Enterprises Internet|                      | Andrew Milton
The Internet (Aust) Pty Ltd          |  M:+61 416 022 411   |
ACN: 082 081 472 ABN: 83 082 081 472 |akm at theinternet.com.au| Carpe Daemon

More information about the freebsd-current mailing list