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

TooManyBitmapsException cause no display AGAIN #1351

Closed
narychen opened this issue Jul 12, 2016 · 6 comments
Closed

TooManyBitmapsException cause no display AGAIN #1351

narychen opened this issue Jul 12, 2016 · 6 comments

Comments

@narychen
Copy link

narychen commented Jul 12, 2016

This problem has been issued many times, but I don't think it has been solved.
I added a comment at the bottom of this issue #213
The image will not show after a long time running if you have a lot of pictures to render because of TooManyBitmapsException.
But imagePipeline.clearCaches() or shutDown() doesn't solve it.
I checked the code in com.facebook.imagepipeline.memory.BitmapCounter and didn't find any code clear the mCount and mSize to zero when you call clearCaches().
So I think there may be something missed here.

@huangjunkun
Copy link

huangjunkun commented Jul 12, 2016

@narychen Truth is that You are negligent. Look the follow code.


  /**
   * Pins the bitmap
   */
  public CloseableReference<Bitmap> pinBitmap(Bitmap bitmap) {
    try {
      // Real decoding happens here - if the image was corrupted, this will throw an exception
      Bitmaps.pinBitmap(bitmap);
    } catch (Exception e) {
      bitmap.recycle();
      throw Throwables.propagate(e);
    }
    if (!mUnpooledBitmapsCounter.increase(bitmap)) {
      bitmap.recycle();
      throw new TooManyBitmapsException();
    }
    return CloseableReference.of(bitmap, mUnpooledBitmapsCounter.getReleaser());
  }

*Decrease the mCount and mSize By mUnpooledBitmapsCounter.getReleaser(), returned as a CloseableReference . *

@narychen
Copy link
Author

@huangjunkun Maybe you were right.
But I added the following code

    ImagePipeline imagePipeline = Fresco.getImagePipeline();
    imagePipeline.clearCaches();
    int count = BitmapCounterProvider.get().getCount();
    long size = BitmapCounterProvider.get().getSize();
    FLog.d("LoggingListener", "-"+count+"-"+size);

And the output is
D/unknown:LoggingListener: -9-8905536
I execute it a few times, the count is always 9

@narychen
Copy link
Author

And I set breakpoint at pinBitmap() and call clearCaches(), it will not be called.
335fb134-1f57-41fe-a756-6a162e945d88

After using a while the mCount raise up to 64 and call clearCaches() still could not decrease it.

1ed0857d-36f6-471c-94d3-4761cbad6292

There must be some leaks at somewhere.

@huangjunkun
Copy link

@narychen
Yeah, it must be some leaks at somewhere. You check your code again carefully.

@narychen
Copy link
Author

narychen commented Jul 14, 2016

I found that quit the app and launch again will lead to bitmapCounter start counting on the number of what you last quit and never decrease down below that number.
I've got a more specific description on facebook/react-native#8677 (comment)

I think there may be some problem with the special region of Android memory where decompressed image stored on On Android 4.x and lower.
Because I noticed that the memory usage is very low at about 20M-30M on my phone of android 4.3. But when I browse a lot of images, the app will still crash with the error of

<sharedmem_gpumem_alloc_id:1427>: sharedmem_gpumem_alloc: mmap failed errno 12 Out of memory

@erikandre
Copy link
Contributor

Duplicating to #1980

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

No branches or pull requests

3 participants