Core Java

Java Mission Control 5.2 is Finally Here! Welcome 7u40!

It has been a while since we last heard of this fancy little thing called Mission Control. It came all the way from JRockit and was renamed to Java Mission Control. This is one of the parts which literally survived the convergence strategy between HotSpot and JRockit. With today’s Java SE 7 Update 40 you can actually use it again.

Java Mission Control 5.2

The former JRockit Mission Control (JRMC) is now called Java Mission Control (JMC) and is a tools suite which includes tools to monitor, manage, profile, and eliminate memory leaks in your Java application without introducing the performance overhead normally associated with tools of this type. Up to today the 5.1 version was available within the Oracle HotSpot downloads which could only be received by paying customers from the Oracle Support Website. Todays release is the first release of Java Mission Control that is bundled with the Hotspot JDK! The convergence project between JRockit and Hotspot has reached critical mass. With the 7u40 release of the Hotspot JDK there is an equivalent amount of Flight Recorder information available from Hotspot. And having it finally makes sense. Beside hundreds of minor fixes and improvements the JMC Client is now build to run on Eclipse 3.8.2/4.2.2 and is also featuring a new JVM Browser with server-side subnotes. This makes tracking of running recordings and JVMs a lot easier.

Java Flight Recorder (JFR)

But the main and most important feature is the Flight Recorder. The Flight Recording feature work with events. Those events need to be produced by the underlying JVM. Hotspot has now reached event convergence with JRockit. That means that most useful information that was provided from JRockit is now also available from Hotspot. And because those are quite different JVMs; the information will in some cases be a bit different. The overall profiling overhead for your applications still stays at less than 2%. Usually much less. Which, considering the information you get, is next to nothing.

JFR with GlassFish 4

Lets get your hands dirty and try this with latest GlassFish. First change your glassfish4\glassfish\config\asenv.conf/.bat and add AS_JAVA=PATH/TO/JDK7u40 now start the domain and navigate to the JVM options. Or as an alternative open glassfish4\glassfish\domains\domain1\config\domain.xml and search for the relevant java-config tag and add the following two jvm-options:

    <jvm-options>-XX:+UnlockCommercialFeatures</jvm-options>
  <jvm-options>-XX:+FlightRecorder</jvm-options>

Now restart the domain and look for the jdk1.7.0_40\bin\jmc and fire it up. If you’re running on the same machine you should already see a list of available JVMs in the JVM Browser. If you expand the GlassFish node and double click the “MBean Server” node you get a nice overview over what is happening right now:

overvoew

From there you can start a flight recording by right clicking the “Flight Recorder” node in the JVM Browser. Select the desired recording time and event settings (which now btw have a new template feature to pre select events and click finish. After the desired timeframe the recording gets downloaded to JMC and you can look through the timeline and find bottlenecks.

A very small drawback is, that you can’t run it with GlassFish 3. There is a know bug which got fixed for the 4.0 release about ordering of the jvm-options.

What is hot?

The best thing since sliced breed is, that you now have method profiling events! With the method profiling events you can find out where your application is spending the most time executing your Java code. This is, for instance, useful to optimize the application where the optimizations actually have an impact.

method_profiling

Further on you have an improved allocation profiling tab.You can now see per TLAB allocation with traces, and object being allocated directly in old space. That “new and improved” theme continues throughout the all tabs in the flight recorder. You get a File I/O, Socket I/O and many many more which provide plenty of insights.

Experimental Plugins

And the best part for me is that the team keep going with a bunch of experimental plugins. A new one was added called JOverflow – Heap dump analysis for memory waste. This plug-in allows Mission Control to do heap dump analysis, primarily to look for wasted heap space. There are several different anti-patterns JOverflow will look for, such as duplicate strings, underutilized collections etc. This plug-in also adds an action (for local connections) that will perform a heap dump and then visualize the heap dump with JOverflow. This is somehow a short term replacement for the Memleak Analyzer which you might know from JRMC. The D-Trace Plugins also got a major overhaul. You can find out more about it on Marcus Hirt’s blog.

Download and Further Reading

You can grep the latest 7u40 download from the Oracle Technology Network Java SE Download Page. Java Mission control is already integrated and you’re ready to run it.

If you need more information visit oracle.com/missioncontrol where you can find the links to the documentation and Eclipse update sites.
 

Markus Eisele

Markus is a Developer Advocate at Red Hat and focuses on JBoss Middleware. He is working with Java EE servers from different vendors since more than 14 years and talks about his favorite topics around Java EE on conferences all over the world. He has been a principle consultant and worked with different customers on all kinds of Java EE related applications and solutions. Beside that he has always been a prolific blogger, writer and tech editor for different Java EE related books. He is an active member of the German DOAG e.V. and it's representative on the iJUG e.V. As a Java Champion and former ACE Director he is well known in the community. Follow him on Twitter @myfear.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Back to top button