In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail the example analysis of garbage collection log, thread dump and heap dump in Java. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
The Java virtual machine (JVM) generates three key components that are useful for optimizing performance and troubleshooting production problems. These components are:
Garbage collection (GC) log
Thread dump
Heap dump
In this article, let's try to understand these three key components, where they are used, how they look, how to capture them, how to analyze them, and their differences.
1. Garbage collection log a) what is a GC log?
GC Log contains information about garbage collection events. It indicates how many GC events were run, what type of GC events they were (that is, Young GC or Full GC), the time each GC event paused the application, and how many objects were recycled per GC event.
B) what does the GC log look like?
You can find a sample garbage collection log file here.
C) where is GC Log used?
Garbage collection logs are used to study the GC and memory performance of an application. It is used to optimize GC pause times, to determine the optimal memory size for an application, and to resolve memory-related problems.
D) how to generate GC logs?
You can generate garbage collection logs by passing the following JVM parameters:
For Java versions prior to 8:
-XX:+PrintGCDetails-XX:+PrintGCDateStamps-Xloggc:
For Java versions starting with 9:
-Xlog:gc*:file=
File path: is the location where the garbage collection log file will be written.
E) how to understand GC Log?
Garbage collection log format depends on your JVM vendor (Oracle, HP, IBM, Azul, etc.), Java version (1.5,5,6,7,8,9,10,11,12... ), garbage collection algorithms (serial, parallel, CMS, G1, Shenandoah, Z GC), and passed JVM parameters. Therefore, there is no standardized format available.
F) what tools are used to analyze GC logs?
There are several garbage collection log analysis tools. Here are some popular ones: GCeasy, IBM GC and memory Visualizer, HP JMeter, Google Garbage Cat.
two。 Thread dump a) what is a thread dump?
A thread dump is a snapshot of all threads running in the application at some point in time. It contains all the information about each thread in the application, such as thread status, thread ID, native ID, thread name, stack trace, priority.
B) what does the thread dump look like?
You can find sample thread dumps here.
C) where are thread dumps used?
Thread dumps are mainly used to solve production problems, such as peak CPU, unresponsive applications, poor response time, thread hangs, and high memory consumption.
D) how to generate thread dumps?
You can use eight different options to capture thread dumps from a running application. The most common option for thread dumps is to use the "jstack" tool. The jstack tool is available in the JDK_HOME\ bin folder. This is the command you need to issue to capture thread dumps:
Jstack-l >
Where pid: is the process ID of the application, and its thread dump should be captured, and file-path: is the file path where the writing thread will be dumped.
E) what tools are used to analyze thread dumps?
The following are the most widely used thread dump analysis tools: fastThread, Samurai, IBM Thread & Monitor Analyzer, Visual VM.
3. Heap dump a) what is a heap dump
A heap dump is a snapshot of application memory at some point in time. It contains information such as what objects are in memory, what values they carry, how big they are, and what other objects they reference.
B) what does the heap dump look like?
Sample heap dumps can be found here. (note: it will be in binary format. So you can't actually read it.
C) where are heap dumps used?
Heap dumps are mainly used to solve memory-related OutOfMemoryError problems.
D) how to generate heap dumps?
You can use seven different options to capture heap dumps from a running application. The most common option for heap dumps is to use the "jmap" tool. The jmap tool is available in the JDK_HOME\ bin folder. This is the command you need to issue to capture:
Jmap-dump:format=b,file=
Where pid: is the Java process ID, whose heap dump should be captured, and file-path: is the file path that will be written to the heap dump.
E) how to understand heap dumps?
Heap dump files are in binary format and tend to be large. Besides, there is a serious lack of documentation in their format. Therefore, you must use the heap dump analysis tool (given in the next question) to analyze and understand them.
F) what tools are used to analyze Heap dump?
The most widely used heap dump analysis tools: Eclipse MAT, HeapHero, JVisualVM.
This is the end of the article on "sample analysis of garbage collection logs, thread dumps and heap dumps in Java". I hope the above content can be helpful to you so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.