java - 从 LeakTraceElement 检索行号

标签 java memory-leaks stack-trace line-numbers leakcanary

我正在使用LeakCanary来检测内存泄漏。为了跟踪事件,我将 LeakTraceElement 转换为 StackTraceElement,如 "LeakCanary, then what? Nuking Nasty Memory Leaks by Pierre-Yves Ricau" 中所示。 .

Code snippet

我想将行号传递给 StackTraceElement 构造函数:

StackTraceElement(String cls, String method, String file, int line) { /* ... */ }

如何从 LeakCanary 中检索行号

最佳答案

我只是玩了一下这个,在做了一些更多的挖掘之后,看起来该信息在运行时不能直接获得。

How to get line number of an instance variable from a java object during runtime

关于java - 从 LeakTraceElement 检索行号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43845329/

相关文章:

ios - 什么是???在 iOS 中的意思是

java - 遍历堆栈时显示传递的参数值

Java - 按行号更新 JTextArea 中的文本

java - 多线程使用中的变量声明,Java [内存泄漏问题]

java - 从 Fragment 中的 Activity 获取 boolean 值

c++ - 如何在 C++ 中释放分配的静态值?

c++ - 内存泄漏和代码性能

php - PHP配置文件生成器错误

java - JMS 与 Spring 和 Webspehre MQ 集成的 JNDI

java - Docker multi-staged maven build 拆分依赖解析和编译