获取有关特定内存泄漏的更多详细信息

发布于 2024-12-01 11:29:41 字数 465 浏览 0 评论 0原文

我的内存泄漏看起来像这样: leak

由于没有太多使用 Eclipse Memory Analyzer 的经验,我想知道它是否可以回答这两个问题问题:

  • 大多数实例分配的源代码位置是什么?
  • 他们没有被垃圾收集的原因是什么?
    1. 它们是否停止了但仍然在某处被引用?
    2. 他们还在执行还是在睡觉?

编辑:看起来sbridges是对的,我的线程永远不会消失。但是我不太确定原因,因为堆栈跟踪似乎不包含我的任何代码。我使用 ExecutorService 的方式一定是错误的。

线程

My memory leak looks like this:
leak

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?
    1. Did they stop but are still referenced somewhere?
    2. 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.

threads

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浮云落日 2024-12-08 11:29:41

您的代码在某个地方创建线程,并且这些线程永远不会消失。线程不能被垃圾收集,因为线程是 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文