android - Android Leak Canary 2 无法转储堆
问题描述
我正在尝试在我的项目中实现 LeakCanary2 以检测内存泄漏,但它不断失败。
2020-07-03 19:37:41.834 17761-17799/com.example.projects D/LeakCanary: WRITE_EXTERNAL_STORAGE permission not granted, ignoring
2020-07-03 19:37:47.912 17761-17799/com.example.projects D/LeakCanary: Dumped heap file is 0 byte length
2020-07-03 19:37:47.914 17761-17799/com.example.projects D/LeakCanary: Failed to dump heap, will retry in 5000 ms
2020-07-03 19:37:47.914 17761-17799/com.example.projects D/LeakCanary: Rescheduling check for retained objects in 5000ms because failed to dump heap
2020-07-03 19:37:53.206 17761-17799/com.example.projects D/LeakCanary: Check for retained objects found 6 objects, dumping the heap
2020-07-03 19:37:53.214 17761-17799/com.example.projects D/LeakCanary: Removing 1 heap dumps
2020-07-03 19:37:53.222 17761-17799/com.example.projects D/LeakCanary: WRITE_EXTERNAL_STORAGE permission not granted, ignoring
它永远在无限循环中进行。如果我手动授予写入外部存储权限,它仍然无法正常工作。
依赖
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.4'
在 Moto G7 上进行测试。在模拟器上测试时,它按预期工作。
解决方案
推荐阅读
- logging - Ideolog (PyCharm):如何为标准日志库配置日志格式
- html - 如何使用 XSLT 将带有嵌入式 HTML 的 XML 转换为嵌入式 XML?
- javascript - Python网页中的Javascript事件处理程序不起作用
- python - 如何计算每组某个班级的重复次数
- java - 如何使用 Retrofit 2 和 Android Studio 获取 JSON 对象?
- flutter - Flutter:如何将 URI 转换为文件?
- html - 如何使用表单输入中的数据重定向到 URL?
- post - 如何通过 Fiddler 脚本修改请求内容中的“Content-Disposition”?
- python-3.x - 如何在 python 3 上使用 RFID 模块 MFRC522-UART 串行?(编码/解码问题)
- android - 系统破坏后如何从片段中适当地恢复android应用程序