Reputation: 97
We've tried jdk 1.7.0_02. Ten days of running give 420 MB memory leak of the following objects:
- java.lang.management.MemoryUsage,
- [C (array of char),
- java.util.HashMap$Entry,
- [Ljava.util.HashMap$Entry (array of HashMap$Entry),
and some others.
This doesn't happen on jdk1.6.x.
First output of the "jmap -histo:live" command:
num #instances #bytes class name
----------------------------------------------
1: 229527 14926888 [C
2: 289290 13885920 java.lang.management.MemoryUsage
3: 321029 10272928 java.util.HashMap$Entry
4: 69923 10262184 <constMethodKlass>
5: 69923 9527672 <methodKlass>
6: 7048 7787040 <constantPoolKlass>
7: 241693 7734176 java.lang.String
8: 2038 5898408 [Ljava.util.concurrent.ConcurrentHashMap$HashEntry;
9: 7048 5479056 <instanceKlassKlass>
10: 5954 4499552 <constantPoolCacheKlass>
11: 67844 4091672 [Ljava.util.HashMap$Entry;
12: 41250 3942848 [B
13: 65649 3151152 java.util.HashMap
14: 71891 2875640 java.util.TreeMap$Entry
...
Total 2320965 138000120
The last output of the "jmap -histo:live" command done in 10 days after the first:
num #instances #bytes class name
----------------------------------------------
1: 3147110 151061280 java.lang.management.MemoryUsage
2: 3178875 101724000 java.util.HashMap$Entry
3: 1087332 53822632 [C
4: 1099503 35184096 java.lang.String
5: 639442 31529224 [Ljava.util.HashMap$Entry;
6: 637247 30587856 java.util.HashMap
7: 629422 25176880 [Ljava.lang.management.MemoryUsage;
8: 314711 17623816 com.sun.management.GcInfo
9: 70107 10292776 <constMethodKlass>
10: 631864 10109824 java.util.HashMap$EntrySet
11: 314711 10070752 sun.management.GcInfoCompositeData
12: 70107 9552696 <methodKlass>
13: 7075 7817080 <constantPoolKlass>
14: 314713 7554128 [Ljava.lang.Integer;
15: 2048 5898744 [Ljava.util.concurrent.ConcurrentHashMap$HashEntry;
16: 7075 5497200 <instanceKlassKlass>
17: 315792 5052672 java.lang.Integer
18: 47680 4912352 [B
...
Total 13206419 558217856
I also have 8 other histograms, made after each day of the tests. They show linear number of objects increasing. This is definitely not a noise. It is a stable leak 42 MB per day.
Did you observe similar behavior? In what scenarios? How did you cope with it?
Upvotes: 0
Views: 1337
Reputation: 533492
Given the code in Java 7 is slightly different (but almost the same) as Java 6. I would expect to see these very subtle differences. I would take the snapshot after another 2 days to see if the JVM is still warming up. Connecting more monitoring clients would increase these values for example (as these are mostly monitoring objects).
If it is a memory leak, at 32K every two days, this could be wasting ~5 MB after a year of running and worth less than 5 cents of memory. Personally I would consider this too small to worry about.
Upvotes: 4