IJSET V6 Issue2 103
IJSET V6 Issue2 103
Abstract- This paper explores the methods, tools, and best practices involved in Java Virtual Machine (JVM) dump
analysis, specifically focusing on thread, heap, and core dumps. The goal is to provide a comprehensive
understanding of how these dumps can be utilized to diagnose performance issues, memory leaks, and application
failures in Java applications.
Keywords- JVM, Core Dump, Thread Dump, Heap Dump, Java, Memory Analysis, Performance Tuning
© 2018 RamaKrishna Manchana. This is an Open Access article distributed under the terms of the Creative Commons Attribution
License (http://creativecommons.org/licenses/by/4.0), which permits unrestricted use, distribution, and reproduction in any medium,
provided the original work is properly credited.
RamaKrishna Manchana. International Journal of Science, Engineering and Technology,
2018, 6:2
JVM, including memory, register values, process and object retention. These tools have made it
context, and loaded libraries, offering a detailed easier to identify problematic areas, such as large
view of the application's execution environment at retained heaps, memory leaks, and deadlocked
the time of failure. threads, without requiring extensive manual
intervention.
Thread Dumps
Thread dumps capture the execution state of all 3. Comparative Studies of Dump Types and
threads within the JVM, including stack traces, Analysis Techniques
method calls, and synchronization status. They are Comparative studies in the field have explored the
particularly useful for identifying performance effectiveness of different dump types and analysis
bottlenecks, deadlocks, and issues related to thread techniques, focusing on their applicability in various
management in multi-threaded applications. diagnostic scenarios.
2
RamaKrishna Manchana. International Journal of Science, Engineering and Technology,
2018, 6:2
3
RamaKrishna Manchana. International Journal of Science, Engineering and Technology,
2018, 6:2
its memory, register values, process context, and stack trace, method calls, and synchronization
loaded libraries, making them invaluable for post- status. Thread dumps are particularly useful for
mortem analysis of application crashes. diagnosing performance bottlenecks, deadlocks,
and issues related to thread management.
Key Concepts and Components
Memory Snapshot: Captures the entire
memory state of the JVM, including stack, heap,
and program counter values at the time of the
crash.
Crash Diagnostics: Used to diagnose severe
issues such as segmentation faults, illegal
instructions, and other low-level failures.
Operating System Level: Core dumps are
generated by the OS and may require
conversion to be usable by Java diagnostic
tools.
When/Why to Use Core Dump Analysis:
Application Crashes: Core dumps are critical
for understanding why an application crashed,
Key Concepts and Components
especially when it involves low-level system
Stack Trace: Displays the sequence of method
errors.
calls that are currently being executed by each
Hung Processes: Useful for diagnosing
thread.
processes that appear to be hung or
Thread States: Threads can be in various
unresponsive, revealing the underlying cause of
states, such as RUNNABLE, BLOCKED, WAITING,
the hang.
and TIMED_WAITING, each indicating different
Multi-Threaded Issues: Provides visibility into
performance scenarios.
thread states and memory at the time of the
Synchronization and Contention: Thread
crash, helping to identify deadlocks or race
dumps show which threads are waiting for
conditions.
locks, highlighting potential contention points
and deadlocks.
Collection Procedures
When/Why to Use Thread Dump Analysis:
Linux/Solaris: Use coreadm to manage core
Performance Issues: Analyze thread dumps
dump settings and manually trigger dumps
when an application runs slower than expected
with commands like .dump /f crash.dmp.
to identify threads consuming excessive CPU or
Windows: The Dr. Watson utility automatically
waiting for resources.
generates core dumps upon crashes, and
Deadlock Detection: Detect deadlocks where
manual generation can be done using the
two or more threads are stuck waiting on each
.dump command.
other, preventing any progress.
Conversion for Analysis: Core dumps must be
Unresponsive Applications: Troubleshoot
converted to HPROF format using tools like
unresponsive or hanging applications by
jmap (jmap - dump:format=b,file=dump.hprof)
examining what threads are doing and
to be compatible with Java-based analysis
identifying blocking threads.
tools.
Collection Procedures
2. Thread Dump
Manual Collection: Use jstack to manually
A thread dump is a snapshot of all threads running
collect thread dumps, which can also be done
within the JVM at a given point in time. It provides
using graphical tools like JVisualVM and JMC.
a detailed view of each thread’s state, including its
4
RamaKrishna Manchana. International Journal of Science, Engineering and Technology,
2018, 6:2
5
RamaKrishna Manchana. International Journal of Science, Engineering and Technology,
2018, 6:2
1. What are Fatal Error Logs? identifying problematic code paths or resource
A fatal error log is created when a fatal error occurs contentions.
in the JVM, capturing the state of the JVM at the System and Configuration Insights: Use
exact moment of failure. By default, these logs are system details to check for misconfigurations,
generated in the current working directory, but outdated libraries, or incompatible JVM settings
they can also be directed to other locations using that could have contributed to the crash.
the JVM parameter -
XX:ErrorFile=./hs_err_pid<pid>.log. VI. THREAD DUMP ANALYSIS
Key Components of Fatal Error Logs Thread dumps provide a detailed view of what each
Header Section: Provides details about the thread in the JVM is doing at a given moment,
error type, such as the signal or exception that making them vital for diagnosing issues related to
triggered the fatal error. thread management, performance bottlenecks, and
Thread Information Section: Contains application responsiveness.
information about the thread that caused the
error, including the thread’s stack trace. 1. Collection Procedure
Process Information Section: Includes JVM Thread dumps capture the execution state of all
version, configuration details, command-line JVM threads at a specific moment, providing
arguments, and environment variables. insights into thread behavior and resource usage.
System Information Section: Describes the They can be collected both manually and
operating system, CPU details, and native automatically, depending on the diagnostic needs.
libraries loaded at the time of the crash.
Key Tools and Methods
2. When/Why to Use Fatal Error Logs? jstack: A command-line utility included with
Fatal error logs are crucial for diagnosing severe the JDK that captures thread dumps of a
application crashes and unhandled exceptions that running Java process. It is simple to use and
disrupt normal operations. These logs provide provides detailed stack traces for each thread.
insights that are not available through standard JVisualVM: A graphical monitoring tool that
application logs, making them indispensable for: comes with the JDK, offering real-time thread
Understanding Low-Level Failures: Analyzing monitoring and the ability to capture thread
the exact conditions that led to JVM dumps with a single click.
termination. Java Mission Control (JMC): Provides
Post-Mortem Analysis: Reconstructing the advanced monitoring and diagnostic
sequence of events leading up to the crash to capabilities, allowing the capture of thread
identify the root cause. dumps alongside other JVM metrics for a
Improving JVM Stability: Using log data to comprehensive view of application
make informed decisions on JVM tuning, error performance.
handling, and crash prevention strategies.
Automated Collection
3. Analysis Techniques for Fatal Error Logs Thread dumps can be automatically triggered
To analyze fatal error logs effectively, it’s essential using JVM flags such as -
to focus on specific sections that provide the most XX:+PrintConcurrentLocks and -
valuable information: XX:+HeapDumpOnOutOfMemoryError. These
Error Identification: Start by examining the settings help capture thread dumps when
error code, operating system signal, or specific conditions, like high CPU usage or
exception type mentioned in the header. deadlocks, are detected.
Thread and Stack Analysis: Review the stack
trace of the thread that caused the error,
6
RamaKrishna Manchana. International Journal of Science, Engineering and Technology,
2018, 6:2
7
RamaKrishna Manchana. International Journal of Science, Engineering and Technology,
2018, 6:2
8
RamaKrishna Manchana. International Journal of Science, Engineering and Technology,
2018, 6:2
Understanding these challenges and implementing Real-world case studies highlight the effectiveness
mitigation strategies can improve the efficiency and of JVM dump analysis in solving critical
accuracy of dump analysis. performance and stability issues.
These examples provide practical insights into how
1. Large Data Volumes dump analysis can be applied to diagnose and
Challenge: Dumps, especially heap dumps, can be resolve complex problems.
very large, consuming significant disk space and
1. Case Study 1: Resolving a Memory Leak in a
requiring substantial processing power to analyze.
Mitigation: High- Transaction Application
Use Sampling Techniques: Scenario:
Analyze A financial services application
experienced intermittent out-of-memory errors
representative samples of data rather than the
entire dump, focusing on the most critical during peak transaction periods. Initial monitoring
areas. showed abnormal heap growth but did not reveal
Optimize Collection Settings: Configure the the specific cause. Solution: A heap dump was
JVM to collect dumps selectively, targetingcollected during peak usage and analyzed using
specific threads, objects, or conditions toEclipse MAT. The analysis identified a caching
minimize the amount of data captured. mechanism that was retaining objects longer than
necessary, leading to excessive memory
2. Performance Overhead consumption. Outcome: Modifications to the
Challenge: Collecting dumps, particularly heap caching algorithm introduced time-based eviction
dumps, can introduce performance overhead, policies, which reduced the retained heap size by
40% and eliminated the out- of-memory errors.
9
RamaKrishna Manchana. International Journal of Science, Engineering and Technology,
2018, 6:2
10
RamaKrishna Manchana. International Journal of Science, Engineering and Technology,
2018, 6:2
11
RamaKrishna Manchana. International Journal of Science, Engineering and Technology,
2018, 6:2
diagnostics, often requiring tailored solutions for 5. YourKit Profiler: A powerful Java profiler with
short-lived functions and highly distributed in-depth features for JVM analysis. Available at:
microservices. YourKit
6. AppDynamics Java Monitoring: A guide to
XIV. CONCLUSION integrating AppDynamics for monitoring Java
applications. Available at: AppDynamics
JVM dump analysis is a critical practice for 7. New Relic Java Agent: Best practices for
diagnosing and resolving performance, memory, monitoring JVMs using New Relic. Available at:
and stability issues in Java applications. By New Relic
leveraging the detailed data captured in core,
thread, and heap dumps, developers and system
administrators can gain invaluable insights into the
inner workings of their applications, leading to
more effective troubleshooting and optimization.
This paper has covered the essential types of JVM
dumps, their purposes, collection methods, and
detailed analysis techniques, along with best
practices and common challenges. It also
highlighted the tools available for monitoring and
profiling Java applications, demonstrating how they
can be used to enhance diagnostic capabilities.
REFERENCES
12