Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use HSDB to explore the runtime data area

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article shows you how to use HSDB to explore the runtime data area, the content is concise and easy to understand, can definitely make your eyes bright, through the detailed introduction of this article hope you can learn something.

The full name of HSDB is HotSpotDebugger, the debugging tool of HotSpot virtual machine. When you use it, you need the program to be in a paused state. You can use Idea's debug tool directly. Using HSDB, you can see the relevant content in the stack

Start HSDB

No matter which way to start, you need to know the process number of the current java program first. We use the jps command, as shown in the following figure:

Then we use the command jhsdb hsdb-- pid=87854 to start HSDB, as shown in the following figure:

Use HSDB to view JVM virtual machine stack information

We know that when creating a thread, one will assign a jvm stack to it. As shown in the figure above, we can see that there are five threads in java Threads. We select the main thread, and then click the icon above to view the stack information, as shown in the following figure:

1: on the original java Threads panel, click the second button to summon the Stack Memory for main panel.

The main body of the Stack Memory for main panel has three parts, as described in the figure above.

2: the leftmost is the memory address of the stack

3: the middle column is the value stored in this address (mostly the address of other objects)

4: on the far right is the description of HotSpot

5: in the description on the right, we can have two stack frames in the stack (Frame)

You see Young com/platform/tools/jvm/Main$TestObject, the object we defined, and remember that the address 0x00000001161d11e0 represents that the object is referenced in the stack.

Use HSDB to view heap information

Most of our objects are in the heap, so we can use HSDB to see how many instance objects there are in the heap, as shown in the following figure

1: click Tools- > Object Histogram to open the Object Histogram panel on the right

2: enter the full name of our class at 2, then click 3 telescope to search, and our class will be displayed below. There are three examples.

4: you can double-click to select our class, or you can magnify it. You can open the Show Objects of Type panel to see the details of the three instances.

The third of them is the member variable in the method we see in the stack.

For the other two, you need to use a reverse pointer query to see which class references this instance and which variable

HSDB uses revptrs to view instance references

For the two addresses above, we are not sure what they are, so we can check back through the pointer to see what they are referenced, as shown in the following figure:

As shown in the figure above, we can see that one referenced by the Class object is a class static variable, and one referenced by jvm/Main, our Main class, is a class member variable. From this we can also conclude that static variables are actually stored in the heap.

The relationship between Class,static and Klass

This version of hsdb does not support some instructions, such as mem, whatis, etc., so partners who want to learn more can use jdk1.8 's hsdb to try the above two commands.

Multiple Java objects (Java Object, in the heap) correspond to the same Klass (in MetaSpace) to the same Class object (in the heap), and the static variable address of the class exists after the Class object (so it is also in the heap).

The above is how to use HSDB to explore the runtime data area. have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report