VisualVM: See (What's in) Your Heap!
The newly released VisualVM 1.3.7 introduces several cool new features. The most interesting one is displaying "logical value" of objects in the heap browser, including for example String values, File paths and even a preview of UI elements. More details are provided below in the article.
Application JFrame rendered from .hprof heap snapshot
The other improvements in this release include displaying Park state in the Threads view, support for remote memory sampling (Java 8 applications) and displaying Total time values in CPU Hot Spots. The instrumenting Profiler now calibrates JVMs of target applications as needed and allows to manage the calibration data (Tools | Options | Profiling). JMX Connections newly provide an option to not require SSL to suppress security warnings.
Let's explore the heap viewer improvements in more details. The first change is displaying logical values of objects in all views. This includes String-based objects (String, File or URL), Number-based objects (Integer, Long or Float), basic AWT classes (Point, Dimension or Rectangle), Reference objects, Thread objects and many other types.
String values of ThreadGroups and Threads
To provide more information for the selected object, a special preview area has been added to the Instances view. Full String value or primitive array items are displayed here as well as Color, Font or Image previews.
Preview of an int array
The preview area can also render selected UI elements like labels or buttons or content of containers like panels and frames up to the main application window. This way the heap viewer helps to visualize the application state at the point when an OutOfMemoryError occured, discover leaking dialogs and identify duplicate resources.
JPanel rendered from .hprof heap snapshot
Go and download VisualVM for free to see what's in your heap!
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)