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 > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces how to analyze the Serviceability Agent in the Java virtual machine. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.
Debugging and Troubleshooting tools play an important role in the analysis and diagnosis of problems. There is a handy tool that can save a lot of energy and quickly solve the work that would take a long time. But there are fewer tools at the Low Level to JVM level than analytics applications.
For example, sometimes when you analyze an application problem, you want to understand the current memory structure of the application, the contents of the loading class, thread Stack Memory, deadlock analysis, survival object statistics and queries, and so on.
Which tool is more appropriate for all of the above? These relatively low-level analyses can only be correctly analyzed by relying on the support of JVM. Fortunately, the authorities have provided such a tool.
This is the tool we are going to talk about this time, or a tool set to be exact, but it gives us an one-stop feeling when we use it. To accomplish a large number of requirements in one tool, it is Serviceability Agent, which is more often called SA.
What is SA?
The Serviceability Agent is a Sun private component in the HotSpot repository that was developed by HotSpot engineers to assist in debugging HotSpot. They then realized that SA could be used to craft serviceability tools for end users since it can expose Java objects as well as HotSpot data structures both in running processes and in core files.
In a nutshell, this is a tool provided by Sun (Oracle) for analyzing data in the HotSpot runtime and Core files. You can attach to the Java process or analyze the data in the Core file to understand the loaded class, which is a toolset that contains a large number of Java API and tools.
Moreover, after attatch to the process, SA suspends the execution of the current process and gets a snapshot of the process. The current process continues after the SA is disconnected.
How to use it
SA is provided as a Jar file in JDK and is located in JAVA_HOME/lib/sa-jdi.jar. Same as normal Jar file execution. SA provides two ways to use it
HSDB in GUI mode
CLIHSDB of the command line.
For example, when we use GUI, change to this directory and execute the following command:
Java-cp sa-jdi.jar sun.jvm.hotspot.HSDB
Select Attach to HotSpot Process under the File menu, and enter the pid of the Java process.
At this point, you will see that the threads of the process are shown in the list.
A series of icons at the top can view the information of the selected thread, such as the ability to Inspect, view the structure of the thread object at the VM level, select Stack Memory, and view the data of the stack that contains address information.
The following is the Stack Trace that you want to get through Jstack.
Under the Tools menu, there is a range of tools.
Let's choose a few to give a brief introduction.
Class Browser
With this, you can see all the class loaded by JVM. Information such as methods in the corresponding class can also be found naturally. It also supports bringing a class dump locally. For some situations where the problem can only be analyzed through core files, you can get class to analyze.
The operation is also simple, find the corresponding class, click create class and OK, and the class is generated to the lib directory.
Find Object by Query
This function is similar to SQL by entering the object to be queried in the text box
For example, this:
Select t from java.lang.Thread t
Code Viewer
For a method in a class, sometimes you need to analyze the JVM instruction of the method or the square compiled by JIT. You can use this tool. After entering the address of Class or Method, you will see the corresponding content.
Find Value in Heap
The tool can see if the object still exists in the Heap by specifying the address of the object when it is similar to a GC problem.
Through SA, we can analyze not only the Java application level, but also some JVM level, and even JIT compilation methods, whether GC collects objects, can easily understand, like a JVM microscope, with the help of SA, the problem is nowhere to hide.
On how to parse the Serviceability Agent in the Java virtual machine is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can 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.