简体   繁体   中英

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.

-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. I have to restart the JVM. I am getting the following info from 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. Or Any help to resolve this issues is much appreciated.

Update I also got jmap heap dump info. PS Old generation seems to hold most of the memory even when nobody is using it. 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? It seems to cause memory fragment.

Or you can try to add

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

Also you can add -server It seems always to be used for server side Java application.

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.

The problem could be Xmx and Xms both set to the same large value of 7g. Why don't you set the Xms to a lower value? IMHO, this should be corrected.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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