【翻译】java verbose options
原文链接: http://extreme-java.blogspot.com/2011/01/java-verbose-options-for-running.htmlThere are basically three sub parameters with the javac verbose parameter:
verbose参数有三个基本的子参数:
-verbose:class
-verbose:gc
-verbose:jni
To give you an idea of the number of classes loaded when you fire the java commond, here is the most simple program.
package example.java; public class Test{ public static void main(String args[]) { System.out.println("Hello World"); }}
I will run it using the -verbose:class option to see how many classes have been loaded into the memory. If you are running the program from command line then you can use the command:
java -verbose:class Test
The output shown to you will be:
.............
.............
Hello World
Thus we can see that such a huge number of classes are loaded for a simple Hello World program. You can imagine the number of classes loaded when you have very complex system to automate with web applications also comming into the picture.
The story of verbose doesn't end here. You can also see when a garbage collection runs. This option can be handy when performing garbage collection is serious to your program. The modified code will be:
当垃圾回收对你的程序很重要时,gc子参数就显得很方便了:
package example.java; public class Test{ public static void main(String args[]) { System.out.println("Hello World"); System.gc(); }}
If you run the above program as java -verbose:gc Test, the you will see the following line in the output:
This can suggest you when the garbage collector runs.
On the similar lines, if you run the above Test program with -verbose:jni option then the following output will be shown:
..................
..................
[Dynamic-linking native method java.lang.ClassLoader$NativeLibrary.find ...
Hello World
页:
[1]