Skip to Main Content

Need help creating a recording from JVM startup to JVM shutdown (28.0.1)

Bill SOct 17 2012 — edited Oct 17 2012
I'm trying to record performance of a stand-alone java app from start to finish (memory allocated, CPU level, and other interesting things). I want to start a flight recording when my app starts up and finish the recording when the app exists.

Part 1
Start up is no problem because I can use command line args. Stopping is a bit more tricky because it seems that letting the program terminate naturally causes the recording to error. Since I don't know how long the program will run (somewhere between 20-30 hours), I can't just plug in a duration during startup. If there is a way to do the recording just using command line args, I'm interested in what args to use for the stopping part.

Here is what I tried:
Part 2
The app is mine, so I'm happy to start/stop the recording programmatically too, if that will work. I tried this:
JVMFactory.getJVM().getDiagnosticCommand().execute("start_flightrecording", "name=myname,duration=0,filename=myfilename.jfr");
but it fails with this error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no jmapi in java.library.path
	at java.lang.ClassLoader.loadLibrary(
	at java.lang.Runtime.loadLibrary0(
	at java.lang.System.loadLibrary(
	at bea.jmapi.JVMImpl.<clinit>(
	at com.bea.jvm.JVMFactory$
	at com.bea.jvm.JVMFactory$
	at Method)
	at com.bea.jvm.JVMFactory.createJVM(
	at com.bea.jvm.JVMFactory.getJVM(
	at RunTests.main(
The JRockit book warns about security manager errors (I don't know if this is a security manager error or just a different type of security error). My program is kind of like "", it doesn't run in a container or use any fancy frameworks. I tried adding a policy file, so now my batch file looks like this:
set PATH=D:\jrockit64-R28.0.1\bin;%PATH%
set JAVA_HOME=D:\jrockit64-R28.0.1
java %JVM_ARGS% -jar TestDW.jar 4 21 "2010-05-01 10:00:00 GMT"
and my TestDW.policy file looks like this:
grant { 
	permission com.bea.jvm.ManagementPermission "createInstance";
but that isn't working either and I get this error:
Exception in thread "Main Thread" access denied (java.lang.RuntimePermission setFactory)
	at java.lang.SecurityManager.checkPermission(
	at java.lang.SecurityManager.checkSetFactory(
	at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(
(I created my 'Runnable JAR' file in eclipse)

Any tips on how to start the recording through code would be helpful (or links on the web or page numbers in the JRockit book).

Thank you!
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked due to inactivity on Nov 14 2012
Added on Oct 17 2012
1 comment