views:

520

answers:

5

The following simple code reproduces the growth of java.lang.ref.WeakReference objects in the heap:

public static void main(String[] args) throws Exception {

while (true) {
java.util.logging.Logger.getAnonymousLogger();
Thread.sleep(1);
}
}

Here is the output of jmap command within a few seconds interval:

user@t1007:~> jmap -d64 -histo:live 29201|grep WeakReference
8: 22493 1079664 java.lang.ref.WeakReference
31: 1 32144 [Ljava.lang.ref.WeakReference;
106: 17 952

com.sun.jmx.mbeanserver.WeakIdentityHashMap$IdentityWeakReference
user@t1007:~> jmap -d64 -histo:live 29201|grep WeakReference
8: 23191 1113168 java.lang.ref.WeakReference
31: 1 32144 [Ljava.lang.ref.WeakReference;
103: 17 952

com.sun.jmx.mbeanserver.WeakIdentityHashMap$IdentityWeakReference
user@t1007:~> jmap -d64 -histo:live 29201|grep WeakReference
8: 23804 1142592 java.lang.ref.WeakReference
31: 1 32144 [Ljava.lang.ref.WeakReference;
103: 17 952 com.sun.jmx.mbeanserver.WeakIdentityHashMap$IdentityWeakReference

Note that jmap command forces FullGC.

JVM settings:
export JVM_OPT="\
-d64 \
-Xms200m -Xmx200m \
-XX:MaxNewSize=64m \
-XX:NewSize=64m \
-XX:+UseParNewGC \
-XX:+UseConcMarkSweepGC \
-XX:MaxTenuringThreshold=10 \
-XX:SurvivorRatio=2 \
-XX:CMSInitiatingOccupancyFraction=60 \
-XX:+UseCMSInitiatingOccupancyOnly \
-XX:+CMSParallelRemarkEnabled \
-XX:+DisableExplicitGC \
-XX:+CMSClassUnloadingEnabled \
-XX:+PrintGCTimeStamps \
-XX:+PrintGCDetails \
-XX:+PrintTenuringDistribution \
-XX:+PrintGCApplicationConcurrentTime \
-XX:+PrintGCApplicationStoppedTime \
-XX:+PrintGCApplicationStoppedTime \
-XX:+PrintClassHistogram \
-XX:+ParallelRefProcEnabled \
-XX:SoftRefLRUPolicyMSPerMB=1 \
-verbose:gc \
-Xloggc:$GCLOGFILE"

java version "1.6.0_18"
Java(TM) SE Runtime Environment (build 1.6.0_18-b07)
Java HotSpot(TM) Server VM (build 16.0-b13, mixed mode)

Solaris 10/Sun Fire(TM) T1000 
A: 

Confirmed under JDK 1.6.0_19 and 1.6.0_20, absent under 1.6.0_17:

java version "1.6.0_17" Java(TM) SE Runtime Environment (build 1.6.0_17-b04) Java HotSpot(TM) Server VM (build 14.3-b01, mixed mode)

References leaking pile up in java.util.logging.Logger#kids array, but most probably changes in LogManager caused this.

vt
A: 

I have reproduced this on 1.6.0_19.

If you run the sample application with these java arguments:

-Xms8m -Xmx8m -XX:MaxPermSize=8m

After 10 - 15 minutes it will produce an OutOfMemoryError.

I have filed a bug report with Sun. They will let me know in due time if it has been accepted.

Stijn de Witt
A: 

Sun has accepted this bug in their tracker, but for some reason its not showing up on their website, so I cannot post a link here (yet). Talking to Sun right now to ask them what happened.

Stijn de Witt
A: 

Is this issue publicly viewable yet? Thanks!

Rob Moore
A: 

any hope that this will ever be fixed? as far as I can tell there is no action and the problem continues as of this writing in build 1.6.0_22.

Nick