关于G1的Java 7(JDK 7)垃圾收集和文档 [英] Java 7 (JDK 7) garbage collection and documentation on G1

查看:145
本文介绍了关于G1的Java 7(JDK 7)垃圾收集和文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Java 7 已经出现一段时间了,但我无法找到垃圾收集器配置的任何好资源,特别是新的 G1收集器

我的问题:


  1. G1是默认收集器在Java 7中,如果不是如何激活G1?

  2. g1在Java7中有什么可选设置?

  3. 是否有任何其他更改在Java 7中收集器如 cms 并行收集器

  4. 哪里可以找到有关Java 7垃圾收集的良好文档?


解决方案

在我的Java 1.7版安装中,G1垃圾收集器不是默认设置。 0_01。您可以使用一些额外的命令行选项来查看自己:

 > java -XX:+ PrintCommandLineFlags -XX:+ PrintGCDetails -version 
-XX:InitialHeapSize = 132304640 -XX:MaxHeapSize = 2116874240 -XX:ParallelGCThreads = 4 -XX:+ PrintCommandLineFlags -XX:+ PrintGCDetails -XX:+ UseCompressedOops -XX:-UseLargePagesIndividualAllocation -XX:+ UseParallelGC
Java版本1.7.0_01
Java™SE运行时环境(build 1.7.0_01-b08)
Java HotSpot™64位服务器VM(构建21.1-b02,混合模式)

PSYoungGen总计37696K,使用1293K [0x00000007d5eb0000,0x00000007d88c0000,0x0000000800000000)
eden空间32320K,使用4%[0x00000007d5eb0000,0x00000007d5ff3408 ,0x00000007d7e40000)
from space 5376K,0%used [0x00000007d8380000,0x00000007d8380000,0x00000007d88c0000)
to space 5376K,0%used [0x00000007d7e40000,0x00000007d7e40000,0x00000007d8380000)
PSOldGen total 86144K,used 0K [ 0x0000000781c00000,0x0000000787020000,0x00000007d5eb0000)
对象空间86144K,使用0%[0x0000000781c00000,0x0000000781c0 0000,0x0000000787020000)
PSPermGen总计21248K,使用2032K [0x000000077ca00000,0x000000077dec0000,0x0000000781c00000)
对象空间21248K,使用9%[0x000000077ca00000,0x000000077cbfc288,0x000000077dec0000)



不过,您无需启用实验性选项即可开启G1收藏夹。

 > java -XX:+ PrintCommandLineFlags -XX:+ PrintGCDetails -XX:+ UseG1GC -version 
-XX:InitialHeapSize = 132304640 -XX:MaxHeapSize = 2116874240 -XX:+ PrintCommandLineFlags -XX:+ PrintGCDetails -XX:+ UseCompressedOops - XX:+ UseG1GC -XX:-UseLargePagesIndividualAllocation
java版本1.7.0_01
Java™SE运行时环境(build 1.7.0_01-b08)
Java HotSpot™64-位服务器虚拟机(构建21.1-b02,混合模式)

垃圾优先堆总计130048K,使用0K [0x000000077ca00000,0x0000000784900000,0x00000007fae00000)
区域大小1024K,1个青年(1024K) ,0幸存者(0K)
压缩烫发电池总数20480K,使用2032K [0x00000007fae00000,0x00000007fc200000,0x0000000800000000)
空间20480K,使用9%[0x00000007fae00000,0x00000007faffc288,0x00000007faffc400,0x00000007fc200000)
否共享空间配置。

我不知道你在哪里可以找到任何好的文档。


Java 7 has been out for a while now, but I cannot find any good resources on the configuration of the garbage collectors, specifically the new G1 collector.

My questions:

  1. Is G1 the default collector in Java 7 and if not how do I activate G1?
  2. What optional settings does g1 have in Java7?
  3. Were there any changes made to other collectors like cms or the parallel collector in Java 7?
  4. Where can I find good documentation on garbage collection in Java 7?

解决方案

The G1 garbage collector is not the default in my installation of Java, version 1.7.0_01. You can see for yourself by using with some extra command line options:

> java -XX:+PrintCommandLineFlags -XX:+PrintGCDetails -version
-XX:InitialHeapSize=132304640 -XX:MaxHeapSize=2116874240 -XX:ParallelGCThreads=4 -XX:+PrintCommandLineFlags -XX:+PrintGCDetails -XX:+UseCompressedOops -XX:-UseLargePagesIndividualAllocation -XX:+UseParallelGC
java version "1.7.0_01"
Java(TM) SE Runtime Environment (build 1.7.0_01-b08)
Java HotSpot(TM) 64-Bit Server VM (build 21.1-b02, mixed mode)
Heap
 PSYoungGen      total 37696K, used 1293K [0x00000007d5eb0000, 0x00000007d88c0000, 0x0000000800000000)
  eden space 32320K, 4% used [0x00000007d5eb0000,0x00000007d5ff3408,0x00000007d7e40000)
  from space 5376K, 0% used [0x00000007d8380000,0x00000007d8380000,0x00000007d88c0000)
  to   space 5376K, 0% used [0x00000007d7e40000,0x00000007d7e40000,0x00000007d8380000)
 PSOldGen        total 86144K, used 0K [0x0000000781c00000, 0x0000000787020000, 0x00000007d5eb0000)
  object space 86144K, 0% used [0x0000000781c00000,0x0000000781c00000,0x0000000787020000)
 PSPermGen       total 21248K, used 2032K [0x000000077ca00000, 0x000000077dec0000, 0x0000000781c00000)
  object space 21248K, 9% used [0x000000077ca00000,0x000000077cbfc288,0x000000077dec0000)

You don't need to enable experimental options to turn on the G1 collector any more, though:

> java -XX:+PrintCommandLineFlags -XX:+PrintGCDetails -XX:+UseG1GC -version
-XX:InitialHeapSize=132304640 -XX:MaxHeapSize=2116874240 -XX:+PrintCommandLineFlags -XX:+PrintGCDetails -XX:+UseCompressedOops -XX:+UseG1GC -XX:-UseLargePagesIndividualAllocation
java version "1.7.0_01"
Java(TM) SE Runtime Environment (build 1.7.0_01-b08)
Java HotSpot(TM) 64-Bit Server VM (build 21.1-b02, mixed mode)
Heap
 garbage-first heap   total 130048K, used 0K [0x000000077ca00000, 0x0000000784900000, 0x00000007fae00000)
  region size 1024K, 1 young (1024K), 0 survivors (0K)
 compacting perm gen  total 20480K, used 2032K [0x00000007fae00000, 0x00000007fc200000, 0x0000000800000000)
   the space 20480K,   9% used [0x00000007fae00000, 0x00000007faffc288, 0x00000007faffc400, 0x00000007fc200000)
No shared spaces configured.

I don't know where you can find any good documentation.

这篇关于关于G1的Java 7(JDK 7)垃圾收集和文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆