Background: I'm doing some performance testing on a Java application that gets launched through several layers of indirection, such that I'm not entirely sure that the application is getting launched with the flags that I think it is. I'd like my application to include a sanity check (before it begins its performance test) and include in the results (after the test) information about how the JVM was tuned, such as:
- Which garbage collector was used?
- Was/is it actively doing cpu profiling?
- Was/is it logging gc activity?
- Was/is it in
-Xint
or-Xmixed
mode? - Was/is
-XX:ParallelGCThreads
set -- if so, to what, and if not, what's the default for this build? - Was/is
-XX:UseCompressedOops
on or off? - etc.
Is there any way for Java code to (within a running JVM) query the actual options used for its containing JVM? (Assume that I can't see the command line that launched me, so I can't re-parse those flags.)
If there isn't a general-purpose way to determine this, answers that are specific to a particular JVM implementation are also welcome.
UPDATE:
It's important for the solution to be able to know what the default values are for any value that isn't explicitly supplied on the command-line. Otherwise, it's going to involve a lot of (error-prone) legwork to look up what the default value is for a given combination JVM/platform/version/architecture. I'm testing across a wide variety of JVMs, so I don't want to have to manually figure out what the default setting is for each parameter in each jvm release.
ps -ef
and there you can see all the input argument of that process. That should work for any JVM type. – Wilscam