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

Improve caching of Bitmaps by adding an in-memory LRU cache #66

Open
eduardb opened this issue Oct 3, 2020 · 0 comments
Open

Improve caching of Bitmaps by adding an in-memory LRU cache #66

eduardb opened this issue Oct 3, 2020 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers Hacktoberfest

Comments

@eduardb
Copy link
Collaborator

eduardb commented Oct 3, 2020

Right now, thumbnails that appear on the metadata screen are cached on disk, using the decodeSampledBitmapAndCache() method from the BitmapReader class. This could be improved further by adding an intermediate layer of caching, in-memory LRU cache, implemented using the androidx.collection.LruCache class from AndroidX.

This cache could also be used for the blank Bitmap that currently gets created every time a mask is saved, here:

Bitmap.createBitmap(maskBitmap.width, maskBitmap.height, maskBitmap.config)

An additional requirement would be for this in-memory cache to react to low memory conditions. This can be achieved by overriding the onTrimMemory() method in the Application class, and depending on the level, evict an adequate number of bitmaps, using the trimToSize() method.

Relevant Android guide: https://developer.android.com/topic/performance/graphics/cache-bitmap#memory-cache

@eduardb eduardb added enhancement New feature or request good first issue Good for newcomers Hacktoberfest labels Oct 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers Hacktoberfest
Projects
None yet
Development

No branches or pull requests

1 participant