When I was arranging PPT today, I found that there was no slide with this tool, so I arranged it casually. Strictly speaking, JDB is a JAVA debugging tool. But for the sake of classification, I added the words “performance tools”. In fact, it is only a performance tool, which is not easy to classify. There are only a few specialized performance testing and monitoring tools, but for performance analysis and performance debugging, the tools used are almost never specifically designed for performance.

We know that Windows has WinDEBUG, Linux has GDB, and Java has JDB. It enables dynamic control of Java processes and threads. Command parameters can be looked up online or just help. I won’t list it here because it’s too long. Just list my operations here for your reference.

Server: Add JAVA_OPTIONS in the Java program to run: -xdebug -xrunjDWp :transport=dt_socket,address=8000,server=y,suspend= Y. Suspend can be n if necessary. This is the same thing as a parameter in a Jprofiler connection.

Client: Localhost: ~ Zee $JDB – attach 192.168.1.105:8000 – sourcepath/Users/Zee/Documents/workspace/testProj/SRC / # to connect to a remote JVM, With the source code Setuncaught Java. Lang. Throwable Setdeferred uncaught Java. Lang. Throwable Initializingjdb…

VMStarted: No frames on the current call stack

Main [1]threads # (java.lang.ref.Reference ReferenceHandler)0x153ReferenceHandlercond.waiting(java.lang.ref.FinalizerReferenceHandler)0x153 Reference Handler cond.waiting (java.lang.ref.FinalizerReferenceHandler)0x153ReferenceHandlercond.waiting(java.lang.ref.FinalizerFinalizerThread)0x152 Finalizer cond. waiting (java.lang.Thread)0x151 Signal Dispatcherrunning Groupmain: (java.lang.Thread)0x1 main running

Stop atZee. MemoryTest. OOM. MEMTestDemo: 42 # to set breakpoints

Setbreakpoint Zee.MemoryTest.OOM.MEMTestDemo:42

# breakpoint hit

Breakpoint hit: “thread=main”,Zee.MemoryTest.OOM.MEMTestDemo.main(), line=42 bci=6 42if(args[0].equals(“HeapOOM”)) {

Thread0x1 # enters the thread

The main [1] [1] where # to check the position Zee. MemoryTest. OOM. MEMTestDemo. Main (MEMTestDemo. Java: 42) Localvariables: Main [1] the clear # check the breakpoint Breakpointsset: breakpoint Zee. MemoryTest. OOM. MEMTestDemo: 42

Main [1]cont # continue

where

Nothread specified.

thread 0x1

Main [1]suspend # suspend Allthreads suspended. Main [1] Zee. MemoryTest. OOM. MEMTestDemo. Main (MEMTestDemo. Java: 46) main [1] tracemethods # 0 x1 tracking method calls the main [1] the main [1] cont

Methodentered: Methodentered: “thread=main”, Zee. MemoryTest. OOM. OOMObject. (), the line = 3 bci = 0 3 public class OOMObject {main [1] untracemethods # 0 x1 cancelled tracking main [1] step Single step debugging

Stepcompleted: “thread=main”, Zee.MemoryTest.OOM.MEMTestDemo.main(),line=46 bci=33 46 list.add(newOOMObject());

Main [1] Next # execute a line (stepOVERCalls)

Stepcompleted: “thread=main”, Zee. MemoryTest. OOM. MEMTestDemo. The main (), 45 bci line = = 39 45 while (true) {main [1] look at variable Methodarguments locals # : args= instance of java.lang.String[1] (id=439) Localvariables: List = instance of java.util.ArrayList(id=441) main[1]list # query 42 if(args[0].equals(“HeapOOM”)) {43 Listlist = new ArrayList(); 44 45 while(true) { 46=> list.add(new OOMObject()); 47 } 48 } 49 50 if(args[0].equals(“StackSOF”)) { 51MEMTestDemo memtestdemo = newMEMTestDemo(); ● Main [1]dumplist #dump variable list = {serialVersionUID: 8683452581122892189 DEFAULT_CAPACITY: 10 EMPTY_ELEMENTDATA: instance ofjava.lang.Object[0] (id=442) DEFAULTCAPACITY_EMPTY_ELEMENTDATA: instanceof java.lang.Object[0] (id=443) elementData: instance ofjava.lang.Object[2734845] (id=444) size: 1964611 MAX_ARRAY_SIZE: 2147483639 java.util.AbstractList.modCount: 1964611 java.util.AbstractCollection.MAX_ARRAY_SIZE: 2147483639 }

There are many more things that JDB can do, such as changing variable values in the JVM, monitoring changes to a variable, and so on.

Don’t define what the tool is for, but what you want to achieve. Including when it is used, how to use, there is no unified standard, just to see whether it is suitable.