Java heap analysis - unix1998/technical_notes GitHub Wiki

MAT (Memory Analyzer Tool):

  • History and Functionality: MAT is a powerful and mature open-source tool originally developed for Eclipse. It excels at analyzing heap dumps in various formats (hprof, binary) to identify memory leaks and other memory-related issues. It provides features like:

    • Detailed object inspection to understand object lifecycles.
    • Retention analysis to pinpoint objects holding up memory.
    • Leak suspect reports to highlight potential memory leaks.
    • Visualization tools like dominator trees to understand object relationships.
  • Still Relevant: While MAT might not be the "newest" tool, it remains a popular and widely used option due to its effectiveness, ease of use, and extensive documentation.

Alternatives for Heap Dump Analysis:

  • VisualVM (bundled with JDK): A free and built-in tool that offers basic heap dump analysis capabilities alongside functionalities like monitoring, profiling, and thread dumps.
  • YourKit (commercial tool): Provides in-depth memory analysis features, including heap dump analysis, memory profiling, and leak detection.
  • Eclipse Memory Analyzer (standalone version): A standalone version of MAT is available outside of Eclipse, offering the same core functionalities for heap dump analysis.
  • FastThread (online tool): This online tool allows you to upload heap dumps for analysis, providing insights into memory usage, potential leaks, and object relationships.

Connecting to Running JVM for Live Analysis (JMX):

  • JVisualVM: This tool can connect to a running JVM with JMX enabled (using jmxremote.port) and provide real-time monitoring of memory usage, threads, and other JVM metrics.
  • YourKit: Offers live memory analysis capabilities alongside heap dump analysis, allowing you to inspect memory usage patterns within the running JVM.
  • VisualVM (limited): While JVisualVM primarily focuses on heap dump analysis of offline files, it might offer some basic live memory monitoring features for connected JVMs.

Choosing the Right Tool:

  • For basic analysis and a user-friendly interface, MAT or VisualVM are good starting points.
  • For advanced features, leak detection algorithms, and live memory analysis, consider commercial tools like YourKit.
  • If you need an online tool for quick analysis, FastThread can be a helpful option.

In essence, MAT remains a valuable tool for analyzing Java heap dumps, and several alternative tools offer similar or more advanced functionalities. Additionally, JMX allows connecting to running JVMs for live memory analysis with tools like JVisualVM or YourKit.