最近在跟着“你假笨” 学习JVM,对垃圾回收这块有了翻天覆地的认识(怪之前学的太浅)。
比如 YGC 仍然会 STOP THE WORD
比如 YGC 仍然会 STOP THE WORD
比如 YGC 仍然会 STOP THE WORD
今天有空 学习下GC 日志跟踪下GC状态,这里流水账记录下几个参数,假装自己很努力。
首先用的到的一个参数是
-verbose
verbose:class
打印加载的class信息,如果报class未找到可以开启这个方便排查问题
[Opened /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/lib/rt.jar]
[Loaded java.lang.Object from /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/lib/rt.jar]
[Loaded java.io.Serializable from /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/lib/rt.jar]
verbose:gc
打印GC内存回收时的信息,调试JVM的GC回收必备 等下会用到 稍后详细讲
verbose:jni
打印调用native方法的信息,调试navtive时必备 等下会用到
System.out.println(InetAddress.getLocalHost());
//下面可以看到调用了native方法
[Dynamic-linking native method java.net.InetAddress.init ... JNI]
[Dynamic-linking native method java.net.InetAddressImplFactory.isIPv6Supported ... JNI]
[Dynamic-linking native method java.net.Inet6AddressImpl.getLocalHostName ... JNI]
[Dynamic-linking native method java.net.Inet6AddressImpl.lookupAllHostAddr ... JNI]
[Dynamic-linking native method java.net.Inet4Address.init ... JNI]
[Dynamic-linking native method java.net.Inet6Address.init ... JNI]
[Dynamic-linking native method java.lang.Class.isInstance ... JNI]
tangzhiangdeMBP/192.168.6.191