Name: gm110360 Date: 07/30/2003
FULL PRODUCT VERSION :
java version "1.4.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1
Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)
All windows 32-bit OSs (Win 9x, Me, 2000, & XP).
A DESCRIPTION OF THE PROBLEM :
If a create a JVM through the invocation interface using
JVM.DLL -> JNI_CreateJavaVM and the -Xmx parameter
specifies a heap larger than the VM can allocate, the VM
prints a message to stderr and *completely exits the
I am using the invocation interface to create a VM in-
process of another application. The application is not
JAVA.EXE but a GUI application. The message to stderr is
never seen, and the app disappears w/ no error or acces
violation messages of any kind.
Instead, the JNI_CreateJavaVM should return a failure code
and allow my application to continue and attempt to handle
the failure gracefully (at least giving the user an error
ALSO- According to the Win32 API, specifying a maxSize of 0
to HeapCreate() allows a "virtually limitless" heap. It
will continue growing the heap as large as the operating
system can handle. This is how MSVCRT allocates its heap
for the C/C++ runtime alloc functions. This is far more
convenient - the heap will grow until memory is exhausted,
w/out the user having to "guess" a -Xmx parameter value
(which may cause the JVM to completely wipe out the
Currently, when I try "-Xmx0" as a parameter, the VM
doesn't appear to even try HeapCreate() w/ that parameter,
but prematurely exits, assuming that 0 is indeed an invalid
Invalid maximum heap size: -Xmx0
Could not create the Java virtual machine.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Create a GUI app that creates its own VM via the
invocation interface and passes a very large value as an -
Xmx parameter (like 1800M).
2. Watch the app disappear at runtime w/ no error message.
Running from the command line also results in no error
output since the app is not a console app. The only way to
capture the error message is to redirect the app's output
to a file (either from the command line or
programmatically) and view the output file after the app
EXPECTED VERSUS ACTUAL BEHAVIOR :
I would expect the JNI_CreateJavaVM to return a failure
code and allow my application to continue, handling the
error gracefully if possible (for instance, if the VM is
only needed for one feature that can be disabled at runtime
if the VM create failed).
Also, I would expect -Xmx0 to work as documented in the
Win32 API for HeapCreate.
This bug can be reproduced always.
(Incident Review ID: 166547)