Java GC -- G1

G1垃圾回收器是JDK 7中Java HotSpot VM新引入的垃圾回收器,用于替代HotSpot低延迟的并行标记清除垃圾回收器。

G1是一个server端垃圾回收器。


目前G1仍然是一个试验产品,使用下列参数开启G1回收器:

-XX:+UnlockExperimentalVMOptions -XX:+UseG1GC


设置一个GC暂停间隔:

-XX:MaxGCPauseMillis =50  (停顿间隔50ms)



JDK8: Metaspace

In JDK 8, classes metadata is now stored in the native heap and this space is called Metaspace. There are some new flags added for Metaspace in JDK 8:


  • -XX:MetaspaceSize=<NNN> where <NNN> is the initial amount of space(the initial high-water-mark) allocated for class metadata (in bytes) that may induce a garbage collection to unload classes. The amount is approximate. After the high-water-mark is first reached, the next high-water-mark is managed by the garbage collector


  • -XX:MaxMetaspaceSize=<NNN> where <NNN> is the maximum amount of space to be allocated for class metadata (in bytes). This flag can be used to limit the amount of space allocated for class metadata. This value is approximate. By default there is no limit set.


  • -XX:MinMetaspaceFreeRatio=<NNN> where <NNN> is the minimum percentage of class metadata capacity free after a GC to avoid an increase in the amount of space (high-water-mark) allocated for class metadata that will induce a garbage collection.


  • -XX:MaxMetaspaceFreeRatio=<NNN> where <NNN> is the maximum percentage of class metadata capacity free after a GC to avoid a reduction in the amount of space (high-water-mark) allocated for class metadata that will induce a garbage collection.



参考文献:

About G1 Garbage Collector, Permanent Generation and Metaspace

https://blogs.oracle.com/poonam/entry/about_g1_garbage_collector_permanent


http://lishaofengstar.blog.163.com/blog/static/131972852201242513744835/

http://developer.51cto.com/art/200907/138943.htm




转载于:https://my.oschina.net/darionyaphet/blog/268796

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值