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

Add a pre-filling api for the BitmapPool #93

Closed
sjudd opened this issue Aug 19, 2014 · 4 comments
Closed

Add a pre-filling api for the BitmapPool #93

sjudd opened this issue Aug 19, 2014 · 4 comments
Labels
Milestone

Comments

@sjudd
Copy link
Collaborator

sjudd commented Aug 19, 2014

The BitmapPool api will have to expand a bit:

int getCurrentSize();
int getMaxSize();

Then we could add an api to Glide:

void prefillBitmapPool(TargetSize...);

Where TargetSize is a simple immutable object:

public TargetSize(int width, int height, Bitmap.Config config, float fillPercentage) { }

Each call would make sure at least the given % of the bitmap pool was filled with bitmaps of the given width, height and config.

The allocations can usually be done in a tight loop, but we may want to add something like a time based check to break out of the loop early because occasionally the garbage collector seems to get into a degenerate state where it triggers a GC_FOR_ALLOC for each bitmap in the loop.

@sjudd sjudd added this to the 3.0 milestone Aug 19, 2014
@sjudd sjudd modified the milestones: 3.4, 3.0 Sep 1, 2014
@sjudd
Copy link
Collaborator Author

sjudd commented Sep 25, 2014

Implemented here: 5207906

@AlexBlokh
Copy link

If I'll profile it with images 50x50 and loading images from network one by one they extend the memory. Seems like prefill does nothing. The memory monitor behaves the same way.
Do you use inBitmap flag if there is a bitmap with the needed size in the pool?

@sjudd
Copy link
Collaborator Author

sjudd commented Feb 10, 2015

Maybe your sizes aren't quite right or you're not prefilling with the correct format?

You can turn on verbose logging using:

adb shell setprop log.tag.LruBitmapPool VERBOSE

Doing so will log the contents of the BitmapPool with each request for a Bitmap as well as whether or not a Bitmap was available for the requested width/height/config.

If you're using a device before KitKat, keep in mind that the width, height, and config have to match exactly for you to be able to re-use a Bitmap.

@AlexBlokh
Copy link

I think, this is because of the #333 bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants