疑似内存泄漏 [英] Suspected memory leak

查看:1150
本文介绍了疑似内存泄漏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Eclipse的内存分析器来分析堆转储我的应用程序,因为我觉得我得到的某处内存泄漏。我不能完全肯定要寻找什么,而是在MAT泄漏可疑报告显示4犯罪嫌疑人的问题,分别是:

I'm using Eclipse's Memory Analyzer to analyze a heap dump for my app, since I think I'm getting a memory leak somewhere. I'm not exactly sure what to look for, but the Leak Suspect report in MAT is showing 4 "problem suspects", which are:

 The class "org.apache.harmony.luni.internal.net.www.protocol.jar.JarURLConnectionImpl", loaded by "<system class loader>", occupies 608,976 (16.15%) bytes. The memory is accumulated in one instance of "java.util.jar.JarFile" loaded by "<system class loader>".

 One instance of "org.apache.harmony.xml.ExpatParser" loaded by "<system class loader>" occupies 501,304 (13.29%) bytes. The memory is accumulated in one instance of "java.lang.Object[]" loaded by "<system class loader>".

 127 instances of "org.bouncycastle.jce.provider.X509CertificateObject", loaded by "<system class loader>" occupy 451,280 (11.97%) bytes. These instances are referenced from one instance of "java.util.Hashtable$HashtableEntry[]", loaded by "<system class loader>"

 6,608 instances of "java.lang.String", loaded by "<system class loader>" occupy 407,824 (10.81%) bytes. 

最后一个我猜是,我使用了太多的字符串?其他人我不知道。我没有使用任何加密,所以我不知道为什么BouncyCastle的是显示。

The last one I'm guessing is that I'm using too many Strings? The others I have no clue. I'm not using any encryption, so I don't know why BouncyCastle is showing.

只有code我能想到的是导致了犯罪嫌疑人是这样的:

The only code I can think of that is causing the "suspects" is this:

 final InputStream stream = new URL(feedUrl).openConnection().getInputStream();

 Xml.parse(stream, Xml.Encoding.UTF_8, root.getContentHandler());
 stream.close();

我解析一些偏远的XML文件(使用SAX),大小不等,但没有超过1MB。这code是一个循环,解析约5-6 XML文件的一部分。

I'm parsing some remote XML files (using SAX), of varying sizes, but nothing over 1MB. This code is part of a loop that parses about 5-6 xml files.

任何有识之士至于什么是犯罪嫌疑人的问题是,如果他们所造成内存泄漏和办法解决它,将是极大的AP preciated。

Any insight as to what the "problems suspects" are, if they are causing a memory leak and a way to fix it, would be GREATLY appreciated.

推荐答案

问题嫌疑人只是:首先,寻找内存泄漏。他们的内存顶部用于按对象类型应用程序。这很可能是你没有内存泄漏,但你可以尝试通过这些对象首先寻求减少总体内存使用情况。

The problem suspects are just that: the first place to look for memory leaks. They are the top uses of memory in your application by object type. It is quite possible that you don't have memory leaks, but you can try to reduce memory usage in general by looking at these objects first.

下面是一些资源,了解更多信息。

Here are some resources with more information

  • http://wiki.eclipse.org/index.php/MemoryAnalyzer
  • http://live.eclipse.org/node/520
  • http://memoryanalyzer.blogspot.com/

这篇关于疑似内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆