Skip to main content

Memory leak in jdk1.7.0

3 replies [Last post]
neighbour
Offline
Joined: 2007-11-27
Points: 0

We've tried jdk1.7.0. After two days of running we observed the 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),

This doesn't happen on jdk1.6.x.

First output of the "jmap -histo:live" command:

num #instances #bytes class name
----------------------------------------------
1: 426710 20482080 java.lang.management.MemoryUsage
2: 251358 18621624 [C
3: 448926 14365632 java.util.HashMap$Entry
4: 1877 11657320 [Ljava.util.concurrent.ConcurrentHashMap$HashEntry;
5: 63326 9309352 <constMethodKlass>
6: 63326 8630336 <methodKlass>
7: 234908 7517056 java.lang.String
8: 6365 6970232 <constantPoolKlass>
9: 94584 5828744 [Ljava.util.HashMap$Entry;

Second output of the "jmap -histo:live" command after 2 days of running:

num #instances #bytes class name
----------------------------------------------
1: 426900 20491200 java.lang.management.MemoryUsage
2: 251459 18636704 [C
3: 449116 14371712 java.util.HashMap$Entry
4: 1877 11657320 [Ljava.util.concurrent.ConcurrentHashMap$HashEntry;
5: 63326 9309352 <constMethodKlass>
6: 63326 8630336 <methodKlass>
7: 235009 7520288 java.lang.String
8: 6365 6970232 <constantPoolKlass>
9: 94622 5830568 [Ljava.util.HashMap$Entry;

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
neighbour
Offline
Joined: 2007-11-27
Points: 0

This code reproduces the bug on any Java 7 (7, 7u2 and 7u4 build 11 which is not GA yet).
The corresponding bug on bugs.sun.com: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7128632
Code sample:
----------------------------------------------------

package com.example;



import java.lang.management.ManagementFactory;

import javax.management.MBeanServer;

import javax.management.Notification;

import javax.management.NotificationListener;

import javax.management.ObjectName;



public class GcInfoTest2 {

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



        int iteration = 0;



        MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();

        ObjectName pattern = new

ObjectName(ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE + &quot;,*&quot;);



        for (ObjectName name : mbeanServer.queryNames(pattern, null)) {

            mbeanServer.addNotificationListener(name, new NotificationListener() {

                @Override

                public void handleNotification(Notification notification, Object

handback) {

                    // ignore

                }

            }, null, null);

        }





        while (true) {

            iteration++;

            Object[] garbage = new Object[10000];

            for (int i = 0; i &lt; garbage.length; i++) {

                garbage[i] = new GcInfoTest2();

            }

            if (iteration % 30000 == 0) {

                System.out.println(&quot;garbage[0] = &quot; +

System.identityHashCode(garbage[0]));

            }

        }

    }

}

<br />

jmap output shows that GcInfo instance count constantly increases:

C:\&gt;C:\Java\jdk1.7.0_04\bin\jmap.exe -histo:live 6540 | grep &quot;GcInfo&quot;

  10:         10064         563584  com.sun.management.GcInfo

  15:         10064         241536  sun.management.GcInfoCompositeData

  26:          1943          15544  com.example.GcInfoTest2

180:             2             80  sun.management.GcInfoBuilder

330:             2             16  com.example.GcInfoTest2$1



C:\&gt;C:\Java\jdk1.7.0_04\bin\jmap.exe -histo:live 6540 | grep &quot;GcInfo&quot;

  10:         10128         567168  com.sun.management.GcInfo

  15:         10128         243072  sun.management.GcInfoCompositeData

  23:          7623          60984  com.example.GcInfoTest2

180:             2             80  sun.management.GcInfoBuilder

330:             2             16  com.example.GcInfoTest2$1



C:\&gt;C:\Java\jdk1.7.0_04\bin\jmap.exe -histo:live 6540 | grep &quot;GcInfo&quot;

  10:         10290         576240  com.sun.management.GcInfo

  15:         10290         246960  sun.management.GcInfoCompositeData

  26:          3205          25640  com.example.GcInfoTest2

177:             2             80  sun.management.GcInfoBuilder

306:             2             16  com.example.GcInfoTest2$1
neighbour
Offline
Joined: 2007-11-27
Points: 0

The bug http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7128632 was recently fixed in the 7u4 b13 and was marked as a duplicate of the bug http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7143760 .

BTW, this forum seems to be dead. Use mailing lists instead. http://mail.openjdk.java.net/pipermail/jdk7u-dev/

paddysmith
Offline
Joined: 2012-03-02
Points: 0

Memory leak during startup of weblogic 7.0???????????

-----------------------

STC Technologies|Reputation Management