Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Bug)初始化偶现崩溃问题 #12

Closed
yinshengpan opened this issue Mar 31, 2023 · 1 comment
Closed

(Bug)初始化偶现崩溃问题 #12

yinshengpan opened this issue Mar 31, 2023 · 1 comment

Comments

@yinshengpan
Copy link

implementation "io.github.shixinzhang:android-bitmap-monitor:1.1.0"

        val ctx = ContextUtils.getApplication()
        val cacheFile = File(ctx.cacheDir, "bitmap_monitor")
        if (!cacheFile.exists()) {
            cacheFile.mkdirs()
        }
        val config = BitmapMonitor.Config.Builder()
            // 检查图片是否被回收的间隔,单位:秒 (建议不要太频繁,默认 5秒)
            .checkRecycleInterval(10L)
            // 获取堆栈的阈值,当一张图片占据的内存超过这个数值后就会去抓栈
            .getStackThreshold(100 * 1024L)
            // 还原图片的阈值,当一张图占据的内存超过这个数值后,就会还原出一张原始图片
            .restoreImageThreshold(100 * 1024L)
            .restoreImageDirectory(cacheFile.absolutePath)
            // 是否展示悬浮窗,可实时查看内存大小(建议只在 debug 环境打开)
            .showFloatWindow(true)
            // 重启后清除本地所有文件(目前不支持展示历史数据,所以默认清除本地所有)
            .clearAllFileWhenRestartApp(true)
            // 运行时超出阈值就清理
            .clearFileWhenOutOfThreshold(false)
            // 本地图片缓存写入上限,单位为 byte,默认大小为 512MB,超出后会立刻删除
            .diskCacheLimitBytes(100 * 1024 * 1024L)
            .isDebug(true)
            .context(ctx)
            .build()
        BitmapMonitor.init(config)
java.lang.NullPointerException
	at java.io.File.<init>(File.java:283)
	at top.shixinzhang.bitmapmonitor.internal.BitmapFileWatcher.loadAllFileToMemory(BitmapFileWatcher.java:103)
	at top.shixinzhang.bitmapmonitor.internal.BitmapFileWatcher.$r8$lambda$hPaKz5jeLLZ9ow_IMx3UtPDtUb8(Unknown Source:0)
	at top.shixinzhang.bitmapmonitor.internal.BitmapFileWatcher$$ExternalSyntheticLambda0.run(Unknown Source:0)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
	at java.lang.Thread.run(Thread.java:923)
@yibaoshan
Copy link
Contributor

收到,感谢反馈 (╹▽╹) ,我来跟进看下 ~

yibaoshan added a commit to yibaoshan/AndroidBitmapMonitor that referenced this issue Mar 31, 2023
shixinzhang added a commit that referenced this issue Apr 9, 2023
[fix] issue (#12) 初始化偶现崩溃问题
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants