简体   繁体   English

由于无限的GC,JVM挂起

[英]JVM hangs because of infinite GC

I have a huge application running in glassfish server which creates lot of short-living objects and i have the following GC configuration in JVM. 我有一个巨大的应用程序在glassfish服务器上运行,它创建了许多短生命对象,我在JVM中有以下GC配置。

-XX:+DisableExplicitGC
-XX:+UseParallelGC
-XX:+UseParallelOldGC
-XX:-UseAdaptiveSizePolicy
-XX:PermSize=256m
-XX:MaxPermSize=1024m
-Xms7g
-Xmx7g
-XX:NewRatio=2

But the JVM is hanging with Infinite GC. 但是JVM与Infinite GC一起使用。 I have to restart the JVM. 我必须重新启动JVM。 I am getting the following info from GC Log. 我从GC Log获得以下信息。

2.855: [GC 734029K->9736K(7034240K), 0.0133500 secs]
2.869: [Full GC 9736K->9501K(7034240K), 0.1043570 secs]
13.254: [GC 681231K->26506K(7034240K), 0.0251050 secs]
13.280: [Full GC 26506K->26082K(7034240K), 0.2904930 secs]
13.589: [GC 103156K->26224K(7034240K), 0.0015940 secs]
13.590: [Full GC 26224K->24440K(7034240K), 0.2254710 secs]
35.478: [GC 1859512K->131673K(7034240K), 0.0781300 secs]
41.603: [GC 1966745K->351954K(7034240K), 0.1858590 secs]
46.012: [GC 2187026K->502362K(7034240K), 0.2329020 secs]
51.850: [GC 2337434K->608654K(7034240K), 0.2012410 secs]
72.584: [GC 2443726K->727923K(7034240K), 0.2203390 secs]
80.239: [GC 2562995K->894770K(7034240K), 0.2323490 secs]
106.221: [GC 2729842K->1265916K(7034240K), 0.2800630 secs]

Please let me know whether the jvm GC settings are right for this use case. 请告诉我jvm GC设置是否适合此用例。 Or Any help to resolve this issues is much appreciated. 或者非常感谢任何帮助解决这个问题。

Update I also got jmap heap dump info. 更新我也得到了jmap堆转储信息。 PS Old generation seems to hold most of the memory even when nobody is using it. PS老一代似乎占据了大部分内存,即使没有人使用它。 It is not increasing(which will in case of memory leak). 它没有增加(在内存泄漏的情况下)。

using thread-local object allocation.
Parallel GC with 8 thread(s)

Heap Configuration:
   MinHeapFreeRatio = 40
   MaxHeapFreeRatio = 70
   MaxHeapSize      = 7516192768 (7168.0MB)
   NewSize          = 5439488 (5.1875MB)
   MaxNewSize       = 17592186044415 MB
   OldSize          = 5439488 (5.1875MB)
   NewRatio         = 2
   SurvivorRatio    = 8
   PermSize         = 268435456 (256.0MB)
   MaxPermSize      = 1073741824 (1024.0MB)

Heap Usage:
PS Young Generation
Eden Space:
   capacity = 2244935680 (2140.9375MB)
   used     = 863166976 (823.18017578125MB)
   free     = 1381768704 (1317.75732421875MB)
   38.44951923076923% used
From Space:
   capacity = 112525312 (107.3125MB)
   used     = 47609824 (45.404266357421875MB)
   free     = 64915488 (61.908233642578125MB)
   42.31032392071928% used
To Space:
   capacity = 114753536 (109.4375MB)
   used     = 0 (0.0MB)
   free     = 114753536 (109.4375MB)
   0.0% used
PS Old Generation
   capacity = 5010817024 (4778.6875MB)
   used     = 4385643424 (4182.475494384766MB)
   free     = 625173600 (596.2120056152344MB)
   87.52351967741699% used
PS Perm Generation
   capacity = 458031104 (436.8125MB)
   used     = 432700088 (412.6549606323242MB)
   free     = 25331016 (24.15753936767578MB)
   94.46958606549131% used

Can you cancel the ParallelOldGC? 你能取消ParallelOldGC吗? It seems to cause memory fragment. 它似乎导致内存碎片。

Or you can try to add 或者您可以尝试添加

-XX:+UseCMSCompactAtFullCollection and -XX:CMSFullGCsBeforeCompaction=0 -XX:+ UseCMSCompactAtFullCollection和-XX:CMSFullGCsBeforeCompaction = 0

Also you can add -server It seems always to be used for server side Java application. 您还可以添加-server它似乎总是用于服务器端Java应用程序。

Not sure if it can help. 不确定它是否可以提供帮助。 Because I cannot try it for you. 因为我无法为你尝试。

Not sure it helps, but you can use an additional param: 不确定它有用,但你可以使用额外的参数:

      -XX:ParallelGCThreads=10  //10 threads for GC

to reduce the default number of GC threads. 减少默认的GC线程数。

The problem could be Xmx and Xms both set to the same large value of 7g. 问题可能是Xmx和Xms都设置为相同的7g大值。 Why don't you set the Xms to a lower value? 为什么不将Xms设置为较低的值? IMHO, this should be corrected. 恕我直言,这应该得到纠正。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM