Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java old gen keeps growing - need help interpreting Java GC output

I work on a performance-critical server-side Java application.

Once the system has started, I expect no long-lived objects to be created - only ones with short-ish lives (up to 10 seconds). I therefore want to tune the JVM so that the Old Generation is constant once the system has started up.

I think I've succeeded but I don't understand why (see below).

Here are our settings:

-Xmx3000m -Xms3000m -verbose:gc -XX:+PrintGCTimeStamps -XX:+PrintGCDetails -XX:+UseConcMarkSweepGC -XX:SurvivorRatio=5 -XX:TargetSurvivorRatio=90 -XX:MaxTenuringThreshold=31 -XX:+PrintTenuringDistribution -XX:NewSize=1250m -XX:MaxNewSize=1250m

We're using Oracle's Java 1.6.

I'm really confused by the output of the "PrintTenuringDistribution" flag. I see output like this:

893.866: [GC 893.866: [ParNew
Desired survivor size 168512712 bytes, new threshold 16 (max 31)
- age   1:   13251072 bytes,   13251072 total
- age   2:    1135456 bytes,   14386528 total
- age   3:      59104 bytes,   14445632 total
- age   4:     467384 bytes,   14913016 total
- age   5:      68688 bytes,   14981704 total
- age   6:      43336 bytes,   15025040 total
- age   7:      41344 bytes,   15066384 total
- age   8:       6872 bytes,   15073256 total
- age   9:      87568 bytes,   15160824 total
- age  10:      23840 bytes,   15184664 total
- age  11:      99712 bytes,   15284376 total
- age  12:       5224 bytes,   15289600 total
- age  13:       1000 bytes,   15290600 total
- age  14:      59056 bytes,   15349656 total
- age  15:   65225584 bytes,   80575240 total
: 1015468K->95478K(1097152K), 0.0268070 secs] 1387738K->467748K(2889152K), 0.0269910 secs] [Times: user=0.31 sys=0.00, real=0.03 secs]
899.179: [GC 899.180: [ParNew
Desired survivor size 168512712 bytes, new threshold 16 (max 31)
- age   1:   12438336 bytes,   12438336 total
- age   2:    1531984 bytes,   13970320 total
- age   3:      87920 bytes,   14058240 total
- age   4:      58824 bytes,   14117064 total
- age   5:     463368 bytes,   14580432 total
- age   6:      68688 bytes,   14649120 total
- age   7:      43336 bytes,   14692456 total
- age   8:      40136 bytes,   14732592 total
- age   9:       6872 bytes,   14739464 total
- age  10:      87568 bytes,   14827032 total
- age  11:      23840 bytes,   14850872 total
- age  12:      99712 bytes,   14950584 total
- age  13:       2896 bytes,   14953480 total
- age  14:       1000 bytes,   14954480 total
- age  15:   65282456 bytes,   80236936 total
: 1009782K->98799K(1097152K), 0.0383370 secs] 1382052K->471069K(2889152K), 0.0385490 secs] [Times: user=0.36 sys=0.00, real=0.03 secs]

Given that I have a lot of objects with age=15, and the threshold is 16, I would expect each object in a GC to either (a) get promoted into the Old Generation, or (b) garbage collected.

But according to JConsole my old generation is not increasing. So what's happening to all these objects?

like image 681
Phil Harvey Avatar asked Jul 15 '11 12:07

Phil Harvey


1 Answers

The ages you have are for objects in the survivor space. As you have a large eden space most objects which make into the survivor space will be relatively old.

like image 57
Peter Lawrey Avatar answered Nov 11 '22 12:11

Peter Lawrey