JVM菜鳥進階高手之路十二(jdk9、JVM方面變化, 蹭熱度)


轉載請注明原創出處,謝謝!

經過 4 次跳票,歷經曲折的 Java 9 正式版終於發布了!今天看着到處都是jdk9發布了,新特性說明,心想這么好的蹭熱度計划能錯過嘛,哈哈,所以就發了這篇文章。

目前jdk9和jvm9的規范都還沒有出來,很多細節估計還不清楚,基本就是通過官方介紹,看的。

所以各位看官莫急

去首頁下載jdk9,你會發現:

不這么嚇唬我們,我們一般不會這么快用的

之后下載頁發現和以前的略有不同,沒有32位了。
下載、安裝和以前沒有啥區別,之后運行效果:

Java Platform, Standard Edition What’s New in Oracle JDK 9

主要是基於該地址:New in Oracle JDK 9What’s New for JVM Tuning in JDK 9,其他內容可以自己有興趣的看看,其他的我也沒看。

9999999999999.png

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后續會越來完善的。希望大家對我多多關注,多多支持,點贊點贊,謝謝。


個人公眾號

匠心零度公眾號.jpg


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM