Forum: JRuby [HOWTO] Use Java Mission Control 5.2 with jruby 1.6.x and 1.7.x

2c0c4cf3ccc8da22f7c3b9586ce1cd70?d=identicon&s=25 Christian MICHON (Guest)
on 2013-10-08 07:57
(Received via mailing list)
Hi,

If you've installed JDK 7u40, it has Oracle Java Mission Control 5.2
bundle
in it. The following HOWTO works only with this JDK, not on a JRE. I've
tested it on Win7 Enterprise, but it should definitely work on linux
too!

JMC (in short) can be used as a monitoring system live (like jvisualvm)
but
has a more interesting feature, allowing you to monitor and save a
'flight
record' even without starting jmc.

In order to do so, please add the following 3 options to JRUBY_OPTS:

-J-XX:+UnlockCommercialFeatures -J-XX:+FlightRecorder
-J-XX:FlightRecorderOptions=defaultrecording=true,dumponexit=true

And start the script you wish to monitor. The overhead of creating the
flight record report is supposed to be ~2%. I did not measure it on my
system, but it's definitely low.

For Windows users, you can create such a script to add temporarily the 3
needed options without polluting your JRUBY_OPTS generic settings:
------------------------------
@echo off
setlocal
set JRUBY_OPTS=-J-XX:+UnlockCommercialFeatures -J-XX:+FlightRecorder
-J-XX:FlightRecorderOptions=defaultrecording=true,dumponexit=true
%JRUBY_OPTS%
jruby %1
endlocal
------------------------------

Once the script has completed, in the same directory containing the
jruby
script you monitored, you'll get a file like this
one: hotspot-2013_10_08_07_48_58.jfr

Next steps are very simple: start JMC (type 'jmc' on your prompt,
provided
you configured the JDK path properly), then use the JMC menus to open
the
above mentioned *.jfr file.

You'll get a nice dashboard view, allowing (even days later or on a
different machine) you to monitor the cpu, memory, gc, classes, etc...
metrics saved during that particular run.

Hope this small HOWTO will help you detecting code or memory
bottlenecks.

BR,
Christian
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.