0

I have situation where I start JDK18 jvm from c++ code to produce vst plugin goal being to implement audio signal algorithms in java side with added value of full java GUI api. My framework works very smoothly apart from the repeatable state where my audio streaming crashes after 14 hours. So I thought this is good place to start learning JFR. My jvm starting parameters are in xml file and relevant part is:

<param>
    -XX:StartFlightRecording,dumponexit=true,filename=c:/out/blackbox.jfr
  </param>

Even when application exits that named file keeps empty. So what is the idea of filename parameter if it stays empty and how to use it?

Tonecops
  • 127
  • 9

2 Answers2

0

The recording is dumped in a Java shutdown hook. If you terminate the C++ application with exit(status), the Java hook never gets a chance to run.

Not sure how to best run the shutdown hooks, but you could perhaps invoke System.exit(status) from native using CallStaticVoidMethod?

Kire Haglin
  • 6,569
  • 22
  • 27
  • Ok. It is worth to check. I suspect it also would take host with it to death. C side exit would certainly take plugin host(Cubase) with it which came obvious when I tried freeglut. But delay loaded java has no that problem when removed from track. Java stays alive in background and can be tickled back to action. Currently I'have advanced with JFR to be able to use direct blocking jcmd call with "filename=" to take data where I want. – Tonecops Jul 26 '22 at 21:51
  • jcmd JFR.dump filename=c:/out/mid_dump.jfr understands filename. – Tonecops Jul 26 '22 at 22:00
  • An alternative is to not specify a file, but run with "-XX:StartFlightRecording -XX:FlightRecorderOptions:repository=C:/out", and JFR will keep the last 250 MB (by default). The files are removed in the shutdown hook when the JVM exist, but if it's not happening, you could look at the last file after the crash. It will contain data up to the last second. – Kire Haglin Jul 26 '22 at 22:03
  • The Crash seem to happen in 2D part of the code at 800 minutes. Jvm keeps alive and signal representation freezes and audio freezes. It is quiet. So I should some how find something different around that time. So far jmc GC curve looks perfect. I have 3 ways to check things. 1.Wait 14 hours in real life with Cubase. 2.Call it from C++ simulation but time can be acclerated. 3. Simulate from inside pure java code with accelerated time. I don't have any idea how to spot the error so far other than I can reproduce it and coarsely locate in time. But it is always at 800-820 minutes in with sims. – Tonecops Jul 26 '22 at 22:10
  • I have ugly errors: [0.326s][warning][jfr,start] The .jfc option/setting 'memorysize' doesn't exist. [0.326s][warning][jfr,start] The .jfc option/setting '-XX:FlightRecorderOptions:repository' doesn't exist. – Tonecops Jul 26 '22 at 22:51
  • What is needed in order to isolate the problem is continuous sampling of 30 minute chunks filed to disk with individual names to find something different around the time the freeze occurs. Is that basically in limits of JFR? – Tonecops Jul 26 '22 at 23:00
0

My solution with JDK 18 and flight recorder is not to use JVM startup options at all but instead use jcmd's JFR commands. This is due to incompatible JVM options at startup and lacking documentation. Available documentation is clearly for some older versions of JVM. Here is the available documentation:https://docs.oracle.com/javacomponents/jmc-5-5/jfr-command-reference/toc.htm which proposes use of -XX:+UnlockCommercialFeatures which has been long gone. What is current state of command line options is not achieveable for average programmer. But "jcmd JFR.start" is example of things that work. I got things working observing with "jcmd PID JFR.check" . It is obvious that JFR api is also little bit broken and needs to addressed in a certain way to get the wanted results. There must have been very hurry when implementing it because the order of parameters is very crucial. And there is a nag that "name" must not be a number even it uses it as number. Now I know it is sensitive. So the way I want it to function is to sample and dump periodic chunks so that differences reveal them selves. Now I have the solution to that but it needs another question with no stupid complaints. Baseline is that jcmd with JFR parameter must be used as it comes out of the box in the way which is not obvious.

Tonecops
  • 127
  • 9
  • It's unfortunate that the documentation for JMC 5.5 (released seven years ago) is ranked high when googling. JDK 18 command line reference: https://docs.oracle.com/en/java/javase/18/docs/specs/man/java.html JDK 18 jcmd reference: https://docs.oracle.com/en/java/javase/18/docs/specs/man/jcmd.html – Kire Haglin Jul 27 '22 at 21:28
  • Yes. Solution would build new kind of interface with live hovering dropbox be cut in at that 18 parts. Here all is the same until come /man/ . What is needed is little integration with IDE which happens to bein my case IntelliJ 2021 but I manage to set up to obey versio numbering system for all those JDKs. – Tonecops Jul 30 '22 at 21:27
  • .... at that point 3 days ago I think I got covid (38.9C) and must not formulate all this to proper shape untill the power is back. No more fever but: Still somebody is cutting my brain with knive in five minutes intervals so. any time I 'get' something it comes so this just a little wrong place to be. – Tonecops Jul 30 '22 at 21:39