Java 7 (JDK 7) 垃圾收集和 G1 上的文档
Java 7 已经发布有一段时间了,但是我找不到任何关于垃圾收集器配置的好资源,特别是新的 G1 收集器 >。
我的问题:
- G1 是 Java 7 中的默认收集器吗?如果不是,我该如何激活 G1?
- Java7 中 g1 有哪些可选设置?
- Java 7 中的其他收集器(例如 cms 或 并行收集器)是否有任何更改?
- 在哪里可以找到有关 Java 7 垃圾收集的优秀文档?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
No G1 不是 jdk 1.7.0_02 中默认的垃圾收集器。
默认垃圾收集器取决于机器的类别。
如果机器是服务器类,那么默认的垃圾收集器是吞吐量收集器。
如果机器属于客户端类,则默认垃圾收集器是串行收集器。
No G1 is not default garbage collector in jdk 1.7.0_02.
The default garbage collector depends upon the class of machine.
If the machine is of Server class then the default garbage collector is Throughput Collector.
If the machine is of Client class then the default garbage collector is Serial Collector.
文档位于 http://www.oracle .com/technetwork/java/javase/tech/g1-intro-jsp-135488.html(Wojtek提供的链接)似乎是唯一包含信息的官方链接,但该信息似乎已过时由于提到的一些标志仅在测试版本中可用,因此它们不再存在于生产版本中。 Oracle 的某个人应该提供一些有关 G1 GC 的更新文档。
The documentation available at http://www.oracle.com/technetwork/java/javase/tech/g1-intro-jsp-135488.html (the link provided by Wojtek) seems to be the only official link with info but the info seems outdated as some of the flags mentioned there were only available in the test builds, they no longer exist in the production releases. Some one from Oracle should provide some updated documentation on the G1 GC.
默认情况下,您并不真正想使用 G1 收集器,因为它并不比其他收集器更好。它只适用于特殊目的。
在低延迟应用程序中,它比 CMS 稍好一些,因为它的暂停时间更短、更可预测。 Exchange 中的吞吐量比 CMS 中的 Exchange 差很多。
因此,只有延迟很重要,但吞吐量根本不重要时,这才是好的。如果两者都很重要,那么就继续使用 CMS。
By default you don't really want to use G1 collector, as it is not really better than the others. It is only good for special purposes.
In low latency application is is sligthly better than CMS, as it has a little bit shorter, and more predictable pause times. In exchange the throughput is much worse than CMS in exchange.
So it is only good if the latency is important, but the throughput is not important at all. If both are important, then stay with CMS.
G1 垃圾收集器不是我安装的 Java 版本 1.7.0_01 中的默认设置。您可以通过使用一些额外的命令行选项来亲自查看:
不过,您不再需要启用实验选项来打开 G1 收集器:
我不知道在哪里可以找到任何好的文档。
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:
You don't need to enable experimental options to turn on the G1 collector any more, though:
I don't know where you can find any good documentation.
Oracle 最终在 Java 7 U4 中正式发布了 G1:
http://www.oracle.com/technetwork/java/javase/7u4-relnotes- 1575007.html
说明:
http://docs.oracle.com/javase/7/docs/technotes/ guides/vm/G1.html
命令行选项:
http://www.oracle.com/technetwork/java/javase/ tech/vmoptions-jsp-140102.html#G1Options
不过,我不认为它是 Java 7 中的默认收集器。对于服务器,默认值是 Java 中的并行收集器6.
Oracle finally made G1 official in Java 7 U4:
http://www.oracle.com/technetwork/java/javase/7u4-relnotes-1575007.html
Description:
http://docs.oracle.com/javase/7/docs/technotes/guides/vm/G1.html
Command line options:
http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html#G1Options
Still, I do not think it is the default collector in Java 7. For servers the default is the Parallel Collector as in Java 6.
是的,G1 是 Java 1.7 JVM 中新的标准垃圾收集器。
在这里您可以找到大量有关如何使用和配置新垃圾收集器的信息:
我还发现这篇文章对于理解G1的内部结构非常有帮助。
更多信息此处。
Yes, G1 is the new standard garbage collector in Java 1.7 JVM.
Here you can find plenty of information on how to use and configre the new garbage collector:
I have also found this article very helpful in understanding the inners of G1.
Even more info here.
1. G1 是 Java 7 中的默认收集器吗(...)
此 Java 5 页面 仍然适用于 Java 7(以及 AFAIK、Java 8):
但还要考虑:
-client
VM,因此始终是“服务器类”例如,如果在 Windows x64 上运行...
1。 (...) 如何激活 G1?
从 Java 7 开始,只需
-XX:+UseG1GC
。也许您还感兴趣的是何时想要:2。 Java7 中 g1 有哪些可选设置?
我自己没有使用过 G1,但是
此处列出了特定于 G1 的选项
< EM>3。 Java 7 中的 (...) cms 或并行收集器是否有更改?
不知道,但是...
4。在哪里可以找到有关 Java 7 垃圾收集的优秀文档?
查找起来可能很痛苦,不是吗?我发现的最好的“中心”页面可能是这个:
http://www.oracle.com/technetwork/java/javase/tech/index-jsp-140228.html
需要一些深入阅读,但如果您需要进行一些调整,那么值得花时间。特别有见地的是:垃圾收集器人体工程学
1. Is G1 the default collector in Java 7 (...)
The rule on this Java 5 page is still applicable in Java 7 (and AFAIK, Java 8):
But also consider:
-client
VM, so are always "server class"For example, if on Windows x64 you run...
1. (...) how do I activate G1?
As of Java 7, simply
-XX:+UseG1GC
. Perhaps also of interest is when you would want to:2. What optional settings does g1 have in Java7?
I've not used G1 myself, but I gather that it adheres to the same basic "throughput / ergonomic" flags used to tune the other parallel collectors. In my experience with the Parallel GC,
-XX:GCTimeRatio
has been the pivotal one in providing the expected speed-memory tradeoff. YMMV.G1-specific options are listed here
3. Were there changes to (...) cms or the parallel collector in Java 7?
Don't know, but...
4. Where can I find good documentation on garbage collection in Java 7?
It can be a pain to find, can't it? Probably the best "hub" page I've found is this one:
http://www.oracle.com/technetwork/java/javase/tech/index-jsp-140228.html
Some deep reading required, but worth the time if you need to do some tuning. Particularly insightful is: Garbage Collector Ergonomics
1. G1 是 Java 7 中的默认收集器吗?如果不是,如何激活 G1?
G1 不是 Java 7 中的默认收集器。
-XX:+UseG1GC
将启用 G1GC2。 Java7 中 g1 有哪些可选设置?
有很多。请查看 Oracle 文档页面以获取完整信息。
因此,请自定义关键参数
并将所有其他参数保留为默认值。
您已经重新配置了许多 G1GC 参数,如果您遵循上述文档页面,则不需要这些参数。请交叉检查上述建议,尤其是关于 ParallelGCThreads 和 ConcGCThreads 的建议,它们将基于您的 CPU 内核。删除不必要的参数的重新配置。
年轻代大小:避免使用
-Xmn
选项-XX:NewRatio
显式设置年轻代大小。 固定年轻代的大小会覆盖目标暂停时间目标。3. Java 7 中的其他收集器(例如 cms 或并行收集器)是否有任何更改?
Java 7 有一些更改。看看这个 Oracle 发行说明 页面。
4。在哪里可以找到有关 Java 7 中垃圾收集的良好文档?
请参阅 oracle教程页面
1. Is G1 the default collector in Java 7 and if not how do I activate G1?
G1 is not default collector in Java 7.
-XX:+UseG1GC
will enable G1GC2. What optional settings does g1 have in Java7?
There are many. Have a look at this oracle documentation page for complete information.
Due to this reason, customize critical parameters
and leave all other parameters to default value.
You have re-configured many G1GC parameters, which are not required if you follow above documentation page. Please cross check with above recommendations especially on ParallelGCThreads and ConcGCThreads, which are to be based on your CPU cores. Remove re-configuration of un-necessary parameters.
Young Generation Size: Avoid explicitly setting young generation size with the
-Xmn
option-XX:NewRatio
. Fixing the size of the young generation overrides the target pause-time goal.3. Were there any changes made to other collectors like cms or the parallel collector in Java 7?
There are some changes with Java 7. Have a look at this oracle release notes page.
4. Where can I find good documentation on garbage collection in Java 7?
Refer to oracle tutorial page