There are many versions of activeResources that are discussed and concluded. I looked back at the historical source code to see why this change was made

Change record

The corresponding commitID = e743a1f03f24e33270f38de883b508d4312a7f69, message = Cache resources only after the no remaining consumers.

Modified Content Description

Add Engine#activeResources and resourceReferenceQueue to save active resources with weak references. The key change is LruCache. Get (key); remove(key); Engine#load (key); According to the probability, the continuous access to the same resource is very small, so the resource is difficult to be reclaimed until the cache is full, causing lruCache to remain in a high memory usage state. After the change, every time the cache is hit, the resource cache is immediately removed from the lruCache, effectively avoiding the problem of high memory footprint. Worse, if the system is running out of memory, it can not immediately destroy the resource that will never be accessed a third time to alleviate the memory problem. Memory is generally small). Remove (key); save the removed resource in activeResource. If the resource is accessed a third time and the weak reference has not been reclaimed, it can be used directly.

conclusion

ActiveResources is designed to reduce memory pressure on LRUCache. It is not designed to improve access efficiency and prevent memory leaks. It is not designed to protect images that are being used from being recycled.