Category: Java/.NET Runtime

Q

There is no configuration method for a JVM option I want to specify. Am I out of luck?

A

No, of course not. Even if we did not provide a special property for a certain JVM option, you can configure it via the the indexed DashXOption property .

Use the DashX property for any JVM options that start with "-X" and for which we did not provide a more convenient wrapper API. The following snippet illustrates the correct usage:

IJvmLoader   loader = JvmLoader.GetJvmLoader();

// this sets the maximum heapsize to 256MB
loader.DashXOption[ "mx"] = "256m";
 
// this sets the maximum heapsize to 512MB, overriding the 
// first option
loader.MaximumHeapSizeInMB = 512;

Notice how we broke up the "-Xmx256m" setting into a name ("mx") and a value ("256m"). This helps the runtime library to resolve conflicting settings correctly. You could also have written this:

/// *** don't do this *** ///
IJvmLoader   loader = JvmLoader.GetJvmLoader();

// this correctly sets the maximum heapsize to 256MB
loader.DashXOption[ "mx256m" ] = "";
 
// what happens now ???
loader.MaximumHeapSizeInMB = 512;

The problem with this snippet is that the second configuration call does not know that it overrides the first call's value. Officially, the behavior is undefined, but in all likelihood you will end up with two configuration options: -Xmx256m followed by -Xmx512m. The JVM might treat that as a legal configuration or not, which is why we don't make any claims as to its behavior. To summarize: iIf your -X option has "name" and "value" parts (as in the first snippet above) use the two argument form, otherwise you can use the one argument form.

 


Copyright 2006-2011 by Codemesh, Inc., ALL RIGHTS RESERVED

:
frequently asked questions
home products support customers partners newsroom about us contact us