RFR (S): 7112912:Message "Error occurred during initialization of VM" on boxes with lots of RAM

Thomas Schatzl thomas.schatzl at oracle.com
Wed Mar 13 06:17:42 PDT 2013

Hi all,

  please review the following change which improves ergonomic heap
sizing. Automatic heap sizing now takes available virtual memory into

The problem occurred when the user reduced the available virtual memory
via e.g. ulimit. As ergonomics did not take virtual memory into account,
using available physical memory only, the vm typically crashed at

This patch does not avoid all crashes due to out of virtual memory,
because only heap sizing now takes available virtual memory into account
now. Some GCs, and also other parts of the VM, try to reserve hundreds
of MB at startup.

The main change is in Arguments::allocatable_physical_memory() (which
has been moved from the os class) where if an additional virtual memory
limit has been imposed on the java process, the given heap size is
bounded by a fraction of that limit.

That fraction is determined by a new global called MaxVirtMemFraction
(default value: 2).

Some discussion points:
  - maybe make MaxVirtMemFraction at least notproduct. It does not seem
to make much sense to expose that global to the end user, does it? If
the user is able to change MaxVirtMemFraction, he/she may as well set an
appropriate maximum heap size with the same effect.
  - in the OS specific implementations I kept the code duplication for
the unix targets (bsd, linux, solaris) as it has been before. I think
there is some effort for that going on already.
  - also in 32 bit implementations, the previously used heuristically
found out virtual memory limits (around ~3.8GB) were kept.
  - for querying the virtual memory limit I used getrlimit() with
RLIMIT_AS as parameter. In Solaris there is also RLIMIT_VMEM. Searching
in opensolaris code showed that RLIMIT_AS is just another name for
RLIMIT_VMEM. Additionally, RLIMIT_AS is the only available parameter for
getrlimit() of the two in the posix spec
( http://pubs.opengroup.org/onlinepubs/009696799/functions/getrlimit.html ). This could help later when/if merging the various Unixes.

What do you think?




jprt, local testing with different ulimit values


More information about the hotspot-gc-dev mailing list