简体   繁体   English

如何使用 JProfiler 找到 java memory 泄漏源

[英]How can I find source of java memory leak with JProfiler

I have a memory leak in my program that I've been analyzing with JProfiler.我一直在使用 JProfiler 分析的程序中存在 memory 泄漏。 There are some string values, which I recognize as originating from my program, that are not getting garbage collected.有一些字符串值,我认为它们来自我的程序,但没有被垃圾收集。 However, when looking at the Heap Walker in JProfiler I'm not quite sure how to narrow down the source.但是,在查看 JProfiler 中的 Heap Walker 时,我不太确定如何缩小源范围。

JProfiler 截图

The string is data coming from some HTML parsing I do, however I'm not certain how there is still a reference to the object. All I see is "thread object".该字符串是来自我所做的一些 HTML 解析的数据,但是我不确定如何仍然存在对 object 的引用。我所看到的只是“线程对象”。 How can I find out where the actual memory leak is?我怎样才能找出实际的 memory 泄漏在哪里? Is that possible?那可能吗?

Just looking at the garbage collector root will not always tell you what causes the memory leak, you have to analyze the while reference chain.只看垃圾收集器根并不能总是告诉你是什么原因导致 memory 泄漏,你必须分析 while 引用链。

The screen shot shows a java.util.Stack object in the reference chain that you have put into a java.lang.ThreadLocal .屏幕截图显示参考链中的java.util.Stack object 已放入java.lang.ThreadLocal中。 Thread locals are a common source of memory leaks.线程局部变量是 memory 泄漏的常见来源。

To see which thread local references your objects, select the object(s) of interest in a new object set, then calculate the "Thread locals" inspection in the heap walker.要查看哪个线程局部引用了您的对象,select 新的 object 集合中感兴趣的对象,然后计算堆遍历器中的“线程局部”检查。

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM