aspose file tools*
The moose likes Performance and the fly likes Any advice how to tune GC? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Bookmark "Any advice how to tune GC?" Watch "Any advice how to tune GC?" New topic
Author

Any advice how to tune GC?

Michal Glowacki
Ranch Hand

Joined: Mar 14, 2006
Posts: 114
Hi,

recently I have upgraded my JVM from 1.6 to 1.7 and from that time my server (jboss) is suffering from GC for severals seconds every 5-6 mins. As Java 7 has introduced new GC I have commented out this line in my server start script:



and now it looks like this:



With increasing memory from 4g to 12g I suffer the freezes less often, however obviously they last longer. Please take a look at gc.log when full gc takes place (and server freezes), first is just after start:

2012-02-14T23:28:01.495+0400: 5.485: [Full GC (System) [PSYoungGen: 55632K->0K(3670016K)] [PSOldGen: 0K->54379K(8388608K)] 55632K->54379K(12058624K) [PSPermGen: 23167K->23167K(46848K)], 0.4141070 secs] [Times: user=0.41 sys=0.00, real=0.41 secs]

2012-02-15T00:31:53.580+0400: 3837.523: [Full GC [PSYoungGen: 39308K->0K(4134016K)] [PSOldGen: 8368304K->2662766K(8388608K)] 8407613K->2662766K(12522624K) [PSPermGen: 149854K->149854K(302720K)], 16.6296611 secs] [Times: user=16.63 sys=0.00, real=16.63 secs]

2012-02-15T01:34:52.344+0400: 7616.243: [Full GC [PSYoungGen: 29688K->0K(4140544K)] [PSOldGen: 8359251K->2881431K(8388608K)] 8388939K->2881431K(12529152K) [PSPermGen: 150738K->150738K(302656K)], 17.7303998 secs] [Times: user=17.69 sys=0.00, real=17.74 secs]

2012-02-15T02:09:42.935+0400: 9706.798: [Full GC [PSYoungGen: 75367K->0K(4074880K)] [PSOldGen: 8358495K->2184325K(8388608K)] 8433863K->2184325K(12463488K) [PSPermGen: 151364K->146011K(288256K)], 18.4415495 secs] [Times: user=18.45 sys=0.00, real=18.44 secs]


....

2012-02-15T10:14:51.759+0400: 38815.262: [Full GC [PSYoungGen: 266802K->0K(3765888K)] [PSOldGen: 8361334K->1665185K(8388608K)] 8628137K->1665185K(12154496K) [PSPermGen: 148107K->148107K(279872K)], 14.7845768 secs] [Times: user=14.79 sys=0.00, real=14.79 secs]


As you see it happens now every about 30 mins and freezes server for 14-20 secs! I tried to take heap dump when xmx was set to 4gb, but had to cancel it as only 25% was done and server was already freezed for 3 mins... In my test environment (not big load, tried to load some pages with JMeter) I took a heap dump in YourKit but really cannot locate problematic classes (besides duplicated Strings, but I do not believe that using intern() will solve the problem...) - perhaps anyone familiar with YourKit could give me a tip what to search for?

Anyway, I believe for now I could improve a lot by tunning this GC - perhaps I should go back to parallel collector?

Thanks for all answers,
Michal
Michal Glowacki
Ranch Hand

Joined: Mar 14, 2006
Posts: 114
The problem is that Old Gen pool is growing too fast and needs to be garbage collected. Now I have gone back to concmarksweepgc (btw, to use GC1 in Java 7 I had to put extra params) and set -XX:NewRatio=3 - the old gen is growing much slower and gc takes about 6,5 secs (let's see under bigger load).

Is there any setting for lowering amount of objects being promoted into old gen? young gen is GCed every 5 secs and cause no problems (takes less than 0.1 sec). I use jboss cache and page/application scoped classes so maybe this is the reason of so big amount of data in old gen, however I see no other way to do it.

Any hints?
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 8427
    
  23

Michal Glowacki wrote:recently I have upgraded my JVM from 1.6 to 1.7 and from that time my server (jboss) is suffering from GC for severals seconds every 5-6 mins.
Anyway, I believe for now I could improve a lot by tunning this GC - perhaps I should go back to parallel collector?
...
Thanks for all answers,

Well, if it was me and this was a production environment, I think I'd go back to 1.6 for the moment
unless you have some burning need for using 1.7.

Then you can use the "pause" time to test 1.7 out thoroughly.

Also, have you looked on the JBoss website or a specialized forum to see if this is a known problem?
It's possible that there's a bugfix for it, or others have run into the same issue and found a workaround.

Either way, I would regard any "tweaking" solution as temporary, and keep checking back with them from time to time
for a more comprehensive one.

Winston

PS: Could you please break up that enormous JAVA_OPTS line? It really screws up the panelling software here. Thanks.


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Any advice how to tune GC?