java -verbose command



Blog Category: JAVA Basic
JavaJNI Virtual Machine Windows
java -verbose[:class|gc|jni] Displays the virtual machine running information on the output device.

1.java -verbose:class

How many classes will be loaded when the program is running, a simple program will load hundreds of classes! You can use verbose:class to monitor, enter java -verbose:class XXX (XXX is the program name) on the command line and you will see the loaded class in the console.

verbose and verbose:class have the same meaning, output the information of the class loaded by the virtual machine, and the displayed information format is as follows: [Loaded java.io.FilePermission$1 from shared objects file] Available when the virtual machine reports that the class cannot be found or the class conflicts This parameter is used for diagnostics to see what the virtual machine is loading from the class.

2.java –verbose:gc

displays information on the output device when memory reclamation occurs in the virtual machine. The format is as follows: [Full GC 268K->168K(1984K), 0.0187390 secs] This parameter is used to monitor the memory reclamation of the virtual machine.

01 public class TestGC{ 
02
03 public static void main(String[] args) {  
04
05 TestGC test = new TestGC();  
06
07 System.gc(); 
08
09 }
10
11 }

In this example, a new object is created. Since it is not used, the object quickly becomes reachable. After the program is compiled, execute the command: java -verbose:gc TestGC The result is:

[Full GC 168K->97K(1984K), 0.0253873 secs]

The environment of the machine is Windows 2000 + JDK1.3.1, the data before and after the arrow 168K and 97K respectively represent the memory capacity used by all surviving objects before and after garbage collection GC, indicating that there are 168K-97K= The 71K object capacity is recovered, the data in parentheses is 1984K, the total capacity of the heap memory, and the time required for collection is 0.0253873 seconds (this time will vary for each execution).

3.java –verbose:jni

-verbose:jni outputs the related situation of the native method call, which is generally used to diagnose the error message of the jni call.

When the virtual machine calls the native method, the output device display information, the format is as follows: [Dynamic-linking native method HelloNative.sum ... JNI] This parameter is used to monitor the situation of the virtual machine calling the native method, and it can be used for diagnosis when a jni error occurs. Provide convenience.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326987625&siteId=291194637