Skip to content

Conversation

@ericmiao
Copy link

When an app is moved to background, onTrimMemory() will be called, and LruBitmapPool/MemoryCache will be trimmed. However, the app could keep running and bitmaps will be retired to MemoryCache and LruBitmapPool. In many cases, the amount of memory due to the retired bitmaps in cache is non-trivial.

This change allows an app to limit of the sizes of LruBitmapPool/MemoryCache (by MemoryCategory) when the app is in background, and restore the sizes to normal when it's moved out of background.

@google-cla
Copy link

google-cla bot commented Oct 22, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@ericmiao
Copy link
Author

+@sjudd , note a previous pull request was here #5546, and I had some time to address your feedback)

When an app is moved to background, onTrimMemory() will be called, and
LruBitmapPool/MemoryCache will be trimmed. However, the app could keep
running and bitmaps will be retired to MemoryCache and LruBitmapPool.

This change allows limit of the sizes of LruBitmapPool/MemoryCache (by
MemoryCategory) when the app is in background, and restore the sizes
to normal when it's moved out of background.
@ericmiao ericmiao force-pushed the limit-cache-in-background branch from 4bf6d72 to 0c1d3e8 Compare October 23, 2025 19:04
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

Successfully merging this pull request may close these issues.

1 participant