获取有关特定内存泄漏的更多详细信息
我的内存泄漏看起来像这样:
由于没有太多使用 Eclipse Memory Analyzer
的经验,我想知道它是否可以回答这两个问题问题:
- 大多数实例分配的源代码位置是什么?
- 他们没有被垃圾收集的原因是什么?
- 它们是否停止了但仍然在某处被引用?
- 他们还在执行还是在睡觉?
编辑:看起来sbridges是对的,我的线程永远不会消失。但是我不太确定原因,因为堆栈跟踪似乎不包含我的任何代码。我使用 ExecutorService 的方式一定是错误的。
My memory leak looks like this:
Having not that much experience with the Eclipse Memory Analyzer
i wonder if it can answer those two questions:
- What's the source code position where most of those instances were allocated?
- What's the reason they were not garbage collected?
- Did they stop but are still referenced somewhere?
- Are they still executing or sleeping?
EDIT: Looks like sbridges was right and my threads just never die. However i'm not really sure of the reason since the stacktrace doesn't seem to contain any of my code. The way i use ExecutorService must be wrong somehow.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的代码在某个地方创建线程,并且这些线程永远不会消失。线程不能被垃圾收集,因为线程是 gc 根。调试此问题的最简单方法是启动应用程序,等到有大量线程,然后使用 JConsole,并查看线程的堆栈跟踪。要查看堆栈跟踪,请单击 线程选项卡,然后单击活动线程下的线程。
Somewhere your code is creating threads, and those threads never die. Threads can't be garbage collected, since a thread is a gc root. The easiest way to debug this will be to start the app, wait until you have a large number of threads, then connect to the app with JConsole, and look at the stack traces of the threads. To see stack traces, click on the threads tab and click on a thread under live threads.