You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Explain, please, what is the reason of using ImageViews as keys here:
private Map<ImageView, String> cacheKeysForImageViews = Collections.synchronizedMap(new WeakHashMap<ImageView, String>());
It causes memory leaks. I suppose:
private Map<Integer, String> cacheKeysForImageViews = Collections.synchronizedMap(new HashMap<Integer, String>());
And use imageView.hashCode() as key for this map. This fixes the issue for me.
But may be I miss something?
The text was updated successfully, but these errors were encountered:
cacheKeysForImageViews is used to detect if ImageView was reused to display another image (e.g. in ListView) and prevent loading and displaying previous image in reused ImageView.
Your solution with hashcodes is not bad but it will be terrible if hashcode collision happens.
Why did you decide cacheKeysForImageViews causes memory leaks?
It works fine, while switching between different views and garbage collector does stuff, but I have view, which keeps many child views in cache, and in this case MAT shows cacheKeysForImageViews keys among main memory consumers.
Explain, please, what is the reason of using ImageViews as keys here:
private Map<ImageView, String> cacheKeysForImageViews = Collections.synchronizedMap(new WeakHashMap<ImageView, String>());
It causes memory leaks. I suppose:
private Map<Integer, String> cacheKeysForImageViews = Collections.synchronizedMap(new HashMap<Integer, String>());
And use imageView.hashCode() as key for this map. This fixes the issue for me.
But may be I miss something?
The text was updated successfully, but these errors were encountered: