Java进程有内存泄漏

时间:2014-05-30 08:22:20

标签: java

我有一个Java进程,现在使用1.2GB内存 我用jmap dump一个heap.bin,用内存分析器检查,内存只用了2.4MB 要找到哪个对象使用1.2GB内存?

详细 大小:2.4 MB类:1.2k对象:57.9k类加载器:66个无法到达的对象直方图

Class Name                                                                         | Shallow Heap | Retained Heap | Percentage
class java.io.ObjectStreamClass$Caches @ 0xe1a3f9c0 System Class                   |           16 |       765,096 |     30.94%
sun.misc.Launcher$AppClassLoader @ 0xe55872d0                                      |           72 |       390,664 |     15.80%
org.jdom.Element @ 0xe55a4dc8                                                      |           32 |       343,472 |     13.89%
class com.sun.org.apache.xerces.internal.util.XMLChar @ 0xe18fe228 System Class    |           40 |        65,592 |      2.65%
sun.nio.cs.ext.ExtendedCharsets @ 0xe55acab0                                       |           32 |        64,800 |      2.62%
sun.misc.Launcher$ExtClassLoader @ 0xe55ab718                                      |           72 |        51,792 |      2.09%
sun.text.resources.LocaleElements @ 0xe5552a28                                     |           24 |        50,824 |      2.06%
class java.lang.System @ 0xe155feb0 System Class                                   |           24 |        43,392 |      1.75%
class sun.nio.cs.ext.Big5$Decoder @ 0xe193aab8 System Class                        |           32 |        34,840 |      1.41%
class com.sun.org.apache.xerces.internal.util.EncodingMap @ 0xe1911970 System Class|            8 |        30,496 |      1.23%
sun.text.resources.DateFormatZoneData @ 0xe5552a10                                 |           24 |        25,368 |      1.03%
java.io.PrintStream @ 0xe5592940                                                   |           32 |        25,088 |      1.01%
class java.beans.Introspector @ 0xe1766b10 System Class                            |           64 |        23,424 |      0.95%
class $Proxy1 @ 0xe1b28eb0                                                         |          312 |        23,368 |      0.94%
java.lang.String[560][] @ 0xe55889c0                                               |        2,256 |        20,176 |      0.82%
class sun.security.jca.Providers @ 0xe1a52ed8 System Class                         |           24 |        16,240 |      0.66%
class java.nio.charset.Charset @ 0xe15d5b60 System Class                           |           40 |        12,184 |      0.49%
auo.beol.hisloader.BeolHisLoader @ 0xe55b5848  Thread-4 Thread                     |          160 |        12,064 |      0.49%
auo.beol.hisloader.RecoverHisLoader @ 0xe5651018  Thread-3 Thread                  |          160 |        11,976 |      0.48%
org.jdom.Element @ 0xe55b1520                                                      |           32 |        11,776 |      0.48%
org.apache.log4j.RollingFileAppender @ 0xe55a3350                                  |           72 |        11,512 |      0.47%
org.apache.log4j.RollingFileAppender @ 0xe5587d20                                  |           72 |        11,472 |      0.46%
org.apache.log4j.ConsoleAppender @ 0xe5587e50                                      |           56 |        11,320 |      0.46%
class com.sun.org.apache.xerces.internal.impl.Constants @ 0xe1909fa8 System Class  |          528 |        11,072 |      0.45%
org.apache.log4j.RollingFileAppender @ 0xe55a3590                                  |           72 |        11,000 |      0.44%
org.apache.log4j.RollingFileAppender @ 0xe559b220                                  |           72 |        10,968 |      0.44%
class $Proxy0 @ 0xe1aefcb0                                                         |          160 |        10,672 |      0.43%
auo.cim.util.log.LogThreadData @ 0xe55a44b0                                        |           32 |         8,920 |      0.36%
auo.cim.util.log.LogThreadData @ 0xe5651130                                        |           32 |         8,920 |      0.36%
auo.cim.util.log.LogThreadData @ 0xebf5a038                                        |           32 |         8,920 |      0.36%
Total: 30 of 3,146 entries; 3,116 more                                             |              

2 个答案:

答案 0 :(得分:0)

您可以尝试使用http://visualvm.java.net/heapdump.html

等工具直观地查看堆转储

答案 1 :(得分:0)

必须有一个持有引用的对象,它可能导致内存泄漏。如果您有堆转储,则可以查看哪个类型具有最多的对象,并搜索包含对它们的引用的对象。然后你应该检查你的代码,并找到导致内存泄漏问题的行。

也许这个链接会有所帮助: http://www.javacodegeeks.com/2013/05/monitoring-and-detecting-memory-leaks-in-your-java-application.html

还有一个名为MAT的漂亮工具:http://www.eclipse.org/mat/

它帮助我解决了记忆问题。