2

我正在为我的 java 应用程序微调我的内存参数。我正计划将我的伊甸园空间大小减少到最佳值。

我想知道在年轻一代 GC 周期中幸存下来并被提升为终身代的对象(在年轻一代中创建)的百分比。你能推荐一个可以为我做这件事的工具吗?

我的假设是,如果目前,假设我的年轻一代大小是 x,并且在年轻一代周期中幸存的对象的百分比是 y,如果我将年轻一代减少 5 GB 到 x-5,并且如果幸存的对象百分比年轻一代的周期仍然接近 y,我可以安全地将年轻一代的大小减少到 x-5。

如果您对此有任何意见,请告诉我。

谢谢

4

3 回答 3

1

Sizing Eden Space:

  • you need to compute Allocation Rate (see Advanced JVM Tuning) to determine the size of the your Eden Space.
  • also, Total Young Generation -Xmn should be from 1x to 1.5x of OldGen space occupancy after a full GC (as noted in Java Performance).

Sizing the Survivor Spaces:

  • you need to be watching Promotion Rate (again see Advanced JVM Tuning) so you do not make the FullGC too frequent by decreasing the Survivor/Eden space,
  • -XX:+PrintTenuringDistribution is essential, this will show you the Tenuring Ages,
  • -XX:SurvivorRatio=, -XX:TargetSurvivorRatio= and -XXMaxTenuringThreshold= will be needed to actually tune the Survivor Sizes.
  • See the Request for documentation of -XX:+PrintTenuringDistribution output for more info.
于 2013-03-11T21:16:56.180 回答
0

我最近一直在做测试来弄清楚这一点。我将jstat与 -gc 参数一起使用,并在其输出上使用脚本来获取数字。

通常,每次在 Eden 上进行垃圾收集时,该脚本都会遍历输出并对 Eden 容量 (EC) 求和。最后减去最初使用的伊甸园 (EU) 并在末尾添加 EU。对于 Tenured/Old 空间也是如此。然后存在于 Tenured 上的对象的百分比是使用的总 Tenured Generation Space 除以使用的总 Eden Space。

它需要一些编码,但如果您以后需要进行此类分析,则可以轻松重用。请记住,在使用 jstat 时,您需要一个小于次要垃圾收集之间的时间的间隔才能正确。

于 2013-03-12T08:41:13.410 回答
0

我喜欢 jClarity,但它是一个商业工具,但我相信他们确实有试用期。还有一些开源项目,例如https://code.google.com/p/gclogviewer/

为了让这些 gc 日志查看器正常工作,您需要一些 GC 日志来指向它们。启动时从命令行将以下符文传递给您的 JVM。PrintTenuringDistribution 是您需要告诉您有关任期过程的关键部分。

-Xloggc:gc.log 
-XX:+PrintGCDetails
-XX:+PrintTenuringDistribution
于 2013-03-11T13:47:23.290 回答