【问题标题】:Java - Full GC (Garbage Collector) happening a lot in short interval causing performance hitJava - Full GC(垃圾收集器)在短时间内发生很多导致性能下降
【发布时间】:2013-07-16 23:57:07
【问题描述】:

我在我们的 prod 环境中看到一些异常行为,这导致我们在运行 Tomcat 的服务器上的线程数很高。 10,092,544K 的堆大小在新生代和终身代之间划分为 2,752,512K + 7,340,032K = 10,092,544K。

我很困惑为什么当堆上有足够的内存可用时 GC 会多次运行自己(新旧一代)(Full GC [PSYoungGen: 0K->0K(2752512K)] [ParOldGen: 2748534K-> 2748529K(7340032K)])

正如你所见,年轻一代的 0K->0K 和 .27G -> .27G 的老一代意味着几乎没有任何对象被 gc'd 并且有这么多可用内存。 (堆大小为 10G)。

由于 Full GC 在短时间内运行多次,导致性能下降,因此应用程序无法处理传入的用户请求,因此服务器上的线程数很高,最终我们必须重新启动服务器才能摆脱这种情况。

你能解释一下这里发生了什么吗?

这是 gc.log 上的输出。


。 .

更多…… . .

7 月 18 日 14:52:38 fwprodcontent03 gc.log: 3172.122: [GC [PSYoungGen: 0K->0K(2752512K)] 2750855K->2750855K(10092544K), 0.0515920 秒] [时间:user=0.32 sys=0.01, real=0.06 secs]

7 月 18 日 14:52:42 fwprodcontent03 gc.log: 3172.174: [Full GC [PSYoungGen: 0K->0K(2752512K)] [ParOldGen: 2750855K->2749937K(7340032K)] 2750855K->2749937K(10092544K) [PSPermGen:262143K->262115K(262144K)],4.1571260 秒] [时间: user=44.29 sys=0.06, real=4.15 secs]

7 月 18 日 14:52:42 fwprodcontent03 gc.log: 3176.361: [GC [PSYoungGen: 9071K->1280K(2752512K)] 2759008K->2751217K(10092544K), 0.0989600 秒] [时间:user=0.64 sys=0.01, real=0.10 secs]

7 月 18 日 14:52:46 fwprodcontent03 gc.log: 3176.461: [Full GC [PSYoungGen: 1280K->0K(2752512K)] [ParOldGen: 2749937K->2748847K(7340032K)] 2751217K->2748847K(10092544K) [PSPermGen: 262143K->262121K(262144K)], 3.1331910 秒] [时间: user=31.25 sys=0.01, real=3.14 secs]

7 月 18 日 14:52:46 fwprodcontent03 gc.log: 3179.616: [GC [PSYoungGen: 2161K->288K(2752512K)] 2751008K->2749135K(10092544K), 0.0688890 秒] [时间:user=0.42 sys=0.02, real=0.07 secs]

7 月 18 日 14:52:49 fwprodcontent03 gc.log: 3179.686: [Full GC [PSYoungGen: 288K->0K(2752512K)] [ParOldGen: 2748847K->2748930K(7340032K)] 2749135K->2748930K(10092544K) [PSPermGen: 262143K->262143K(262144K)], 3.2369940 秒] [时间 s: user=32.23 sys=0.02, real=3.23 secs]

7 月 18 日 14:52:49 fwprodcontent03 gc.log: 3182.923: [GC [PSYoungGen: 0K->0K(2752512K)] 2748930K->2748930K(10092544K), 0.0607190 秒] [时间:user=0.39 sys=0.01, real=0.06 secs]

7 月 18 日 14:52:57 fwprodcontent03 gc.log: 3182.984: [Full GC [PSYoungGen: 0K->0K(2752512K)] [ParOldGen: 2748930K->2748528K(7340032K)] 2748930K->2748528K(10092544K) [PSPermGen:262143K->262141K(262144K)],8.5377730 秒] [时间: user=98.30 sys=0.57, real=8.54 secs]

7 月 18 日 14:52:58 fwprodcontent03 gc.log: 3191.533: [GC [PSYoungGen: 202K->128K(2752512K)] 2748731K->2748656K(10092544K), 0.1088430 秒] [时间:user=0.67 sys=0.00, real=0.11 secs]

7 月 18 日 14:53:02 fwprodcontent03 gc.log: 3191.642: [Full GC [PSYoungGen: 128K->0K(2752512K)] [ParOldGen: 2748528K->2748534K(7340032K)] 2748656K->2748534K(10092544K) [PSPermGen: 262143K->262143K(262144K)], 3.1761780 秒] [时间 s: user=31.11 sys=0.02, real=3.18 secs]

7 月 18 日 14:53:02 fwprodcontent03 gc.log: 3194.820: [GC [PSYoungGen: 0K->0K(2752512K)] 2748534K->2748534K(10092544K), 0.0589010 秒] [时间:user=0.38 sys=0.01, real=0.06 secs]

7 月 18 日 14:53:05 fwprodcontent03 gc.log: 3194.879: [Full GC [PSYoungGen: 0K->0K(2752512K)] [ParOldGen: 2748534K->2748529K(7340032K)] 2748534K->2748529K(10092544K) [PSPermGen:262143K->262143K(262144K)],3.0554520 秒] [时间: user=30.72 sys=0.03, real=3.05 secs] 。 . ……更多……


提前致谢。

【问题讨论】:

  • 您可以选择使用并发标记扫描GC吗?
  • @fge - 使用 CMS 不太可能减少完整 GC 的数量。如果有的话,它可能会使事情变得更糟。

标签: java memory-leaks garbage-collection jvm


【解决方案1】:

你看过你的 gc 统计数据了吗?

[Full GC [PSYoungGen: 0K->0K(2752512K)] [ParOldGen: 2748534K->2748529K(7340032K)] 2748534K->2748529K(10092544K) [PSPermGen: 262143K->262143K(262144K)], 3.0554520 secs]

重要的部分是[PSPermGen: 262143K->262143K(262144K)]。您PermGenSpace 已用尽,因此完成了完整的 GC。因此增加你PermGenSpace 来解决这个问题(也许通过减少你的堆空间一点点)。

另外,不要在不重新启动 Tomcat 的情况下经常在生产系统上部署,因为这会很快耗尽您的 PermGenSpace。

【讨论】:

  • 谢谢 Uwe。我忽略了 PermGen 参数。感谢帮助。这回答了我的问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-09-02
  • 2013-06-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-08-25
相关资源
最近更新 更多