轉載請註明原創出處,謝謝! 經過 4 次跳票,歷經曲折的 Java 9 正式版終於發佈了!今天看著到處都是jdk9發佈了,新特性說明,心想這麼好的蹭熱度計劃能錯過嘛,哈哈,所以就發了這篇文章。 目前jdk9和jvm9的規範都還沒有出來,很多細節估計還不清楚,基本就是通過官方介紹,看的。 所以各位看官 ...
轉載請註明原創出處,謝謝!
經過 4 次跳票,歷經曲折的 Java 9 正式版終於發佈了!今天看著到處都是jdk9發佈了,新特性說明,心想這麼好的蹭熱度計劃能錯過嘛,哈哈,所以就發了這篇文章。
目前jdk9和jvm9的規範都還沒有出來,很多細節估計還不清楚,基本就是通過官方介紹,看的。
所以各位看官莫急
去首頁下載jdk9,你會發現:
不這麼嚇唬我們,我們一般不會這麼快用的
之後下載頁發現和以前的略有不同,沒有32位了。
下載、安裝和以前沒有啥區別,之後運行效果:
Java Platform, Standard Edition What’s New in Oracle JDK 9
主要是基於該地址:New in Oracle JDK 9。What’s New for JVM Tuning in JDK 9,其他內容可以自己有興趣的看看,其他的我也沒看。
These are the JVM tuning enhancements in JDK 9.
改善增加G1Usability, Determinism, and Performance
就是內部改進了,詳細的看下描述。
刪除jdk8棄用的垃圾回收器組合
1.下麵組合刪除
- DefNew + CMS
- ParNew + SerialOld
- Incremental CMS
2. foreground的cms gc刪除
foreground它發生的場景比如業務線程請求分配記憶體,但是記憶體不夠了,於是可能觸發一次cms gc,這個過程就必須是要等記憶體分配到了線程才能繼續往下麵走的,因此整個過程必須是STW的,因此CMS GC整個過程都是暫停應用的,但是為了提高效率,它並不是每個階段都會走的,只走其中一些階段,這些省下來的階段主要是並行階段,Precleaning、AbortablePreclean,Resizing這幾個階段都不會經歷,其中sweep階段是同步的,但不管怎麼說如果走了類似foreground的cms gc,那麼整個過程業務線程都是不可用的,效率會影響挺大。
參考:http://mp.weixin.qq.com/s?__biz=MzIzNjI1ODc2OA==&mid=403167528&idx=1&sn=915363f7daaf161c8cf8cd1953d377db&scene=19#wechat_redirect
3.一些jvm參數去掉
- -Xincgc
- -XX:+CMSIncrementalMode
- -XX:+UseCMSCompactAtFullCollection
- -XX:+CMSFullGCsBeforeCompaction
- -XX:+UseCMSCollectionPassing
4. UseParNewGC
The command line flag -XX:+UseParNewGC no longer has an effect. ParNew can only be used with CMS and CMS requires ParNew. Thus, the -XX:+UseParNewGC flag has been deprecated and will likely be removed in a future release.
5. 使用G1做為預設回收器
Risks and Assumptions
- The change is based on the assumption that limiting latency is often more important than maximizing throughput. If this assumption is incorrect then this change might need to be reconsidered.
- G1 is seen as a robust and well-tested collector. It is not expected to have stability problems, but becoming the default collector will increase its visibility and may reveal previously-unknown issues. If a critical issue is found that can't be addressed in the JDK 9 time frame, we will revert back to use Parallel GC as the default for the JDK 9 GA.
- The resource usage of G1 is different from Parallel. When resource usage overhead needs to be minimized a collector other than G1 should be used, and after this change the alternate collector will have to be specified explicitly.
簡單意思就是,與CMS類似,G1更關註的是延遲,如果更關註吞吐量還是建議ps吧,G1已經足夠健壯了,可能有未知沒預測到的,如果解決不了就預設換會PS。6. 統一GC日誌
Reimplements Garbage Collection (GC) logging using the unified JVM logging framework introduced in JEP 158. GC logging is re-implemented in a manner consistent with the current GC logging format; however, some differences exist between the new and old formats.
7. 廢棄CMS
- Deprecates the Concurrent Mark Sweep (CMS) garbage collector. A warning message is issued when it is requested on the command line, using the -XX:+UseConcMarkSweepGC option. The Garbage-First (G1) garbage collector is intended to be a replacement for most uses of CMS.
- 其實通過上面好多項都可以看見把CMS參數去掉很多,之後一些相關也廢棄了,就是想讓G1替代CMS,由於CMS採用的是標記清除,而G1使用的是標記整理所以G1在若幹次GC後,不需要類似CMS那樣必須進行一次碎片整理。
- G1垃圾回收器並沒有特別研究就僅僅瞭解使用標記整理,後面會有空進行學習、分享。
今天大概就這麼多了,也是才出來很多不熟悉,而且只是一點點小部分,後續有空多寫寫,後續Java 將每半年發佈一個版本(壓力大啊),我想想JVM後續會越來完善的。希望大家對我多多關註,多多支持,點贊點贊,謝謝。
個人公眾號