HSDB, javahsdb
HSDB is a debugger used to debug the HotSpot VM. It is a graphical interface. There is also a CLHSDB-Command Line HotSpot Debugger, the Command Line Debugging interface. The following is the startup command:
Java-cp .; % JAVA_HOME %/lib/sa-jdi.jar sun. jvm. hotspot. HSDB # Start the graphical interface java-cp .; % JAVA_HOME %/lib/sa-jdi.jar sun. jvm. hotspot. CLHSDB # Start the command line interface
1. HSDB graphical interface
After HSDB is started, use File-> Attach to HotSpot process to connect to the target process:
After the connection is successful, the Java Threads interface is opened by default. Double-click a thread to view its OOP information, or use the toolbar tool, as shown below:
- Inspector: displays information about OOP and Klass objects. You can also view this information by double-clicking the thread name.
- Stack Memory: thread Stack Memory
- Show Java Stack Traces: displays the thread Stack information.
- Show Thread Infomation: display Thread Information
- Find Crashes
(1) Inspector
(2) Stack Memory
The stack memory interface has three columns of information, from left to right: memory address, indicating that the virtual address is not a physical address. The address data is in the unit of word width, in the case of a 64-bit machine, the word width is 64-bit = 8 bytes. For related notes, the vertical line indicates the range and the horizontal line indicates the description.
The Tools toolbar is also available and has the following features:
- Class Browser: Class Browser
- Code Viewer: view Code
- Compute Reverse Ptrs: Reverse pointer Calculation
- Deadlock Detection: Deadlock Detection
- Find Object by Query: Query objects using the Object Query Language
- Find Pointer: Find Pointer
- Find Value in Heap: query in Heap
- Find Value in Code Cache: query in Code Cache
- Heap Parameters: Heap Information
- Inspector: object checker
- Memory Viewer: Memory information
- Monitor Cache Dump: Monitor Cache Information
- Object Histogram: Object Histogram
- Show System Properties: displays System Properties.
- Show VM Version: displays the VM Version.
- Show-XX flags: displays VM options
Use Heap Parameters to view Heap information and check the address space of each generation:
2. CLHSDB
You can use Windows> Console in HSDB for the command line interface, or use Java commands to directly connect to CLHSDB.
CLHSDB provides a variety of commands to view help information. The following describes common commands:
- Attach pid | exec core: connects to a Java Process or core file.
- Class name: View class information
- Classes: View loaded classes
- Detach: disconnect
- Inspect expression: View OOP Information
- Jstack [-v]: thread Stack
- Mem address [length]: view memory
- Print expression: Output expression value
- Revptrs: reverse pointer
- Scanoops start end [type]: Scan instances of the type and its subclass in the specified space
- Thread {-a | id}: view the specified thread Information
- Threads: View All thread Information
- Universe: View heap space information
- Whatis address: view the data stored at the specified address
- Quit: Exit
Through HSDB and CLHSDB, you can view JVM internal information and understand the working principle of JVM in essence.