glide
glide copied to clipboard
java.util.NoSuchElementException崩溃,LruCache内的currectsize 和cache内的数据size综合差距很大
glide version: implementation 'com.github.penfeizhou.android.animation:glide-plugin:2.16.0' implementation 'com.github.penfeizhou.android.animation:apng:2.16.0' kapt 'com.github.bumptech.glide:compiler:4.11.0'

我们之前发现了这个崩溃: java.util.NoSuchElementException at java.util.LinkedHashMap$LinkedHashIterator.nextNode(LinkedHashMap.java:777) at java.util.LinkedHashMap$LinkedEntryIterator.next(LinkedHashMap.java:808) at java.util.LinkedHashMap$LinkedEntryIterator.next(LinkedHashMap.java:806) at com.bumptech.glide.util.LruCache.trimToSize(LruCache.java:169) app打开在首页,有个循环的banner,图片并没有很大,按理说不会触发trimToSize,在追踪这个问题的时候debug断点LruCache里的put和remove方法,发现currentSize比预想的要大,所以在每次断点处,我都打印了下cache里面的每个的size和总和发现和currectSize不一样,而且隔一会就会差距变得更大。如开始的图所示。total is 3652480 currectsize is 6784136(这时非debug下运行一段时间后的),等再次不进行断点自动运行一会后会变成:total is 3652480 currectsize is 8796056 自己计算打印的total又变回3652480 currectsize 又比之前的 6784136 大了很多,变成了 currectsize is 8796056 。
debug时的代码如图
:
当currectsize大于29.9M时,会触发trimToSize,但这cache里面其实并没有什么,所以就崩溃了
我也碰到了
This issue has been automatically marked as stale because it has not had activity in the last seven days. It will be closed if no further activity occurs within the next seven days. Thank you for your contributions.
所以都是怎么处理的?我配合apng那个库使用的时候也频繁遇到了这个问题...看源码NoSuchElementException是在使用Iterator的next方法取到的元素为null的时候捕获到的异常
what can help?