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

placeholder cause memory leak #910

Closed
bigfreeZhou opened this issue Jan 13, 2016 · 4 comments
Closed

placeholder cause memory leak #910

bigfreeZhou opened this issue Jan 13, 2016 · 4 comments
Labels
needs-details This issue or PR is currently not actionable as it misses details (e.g. for reproducing the problem)

Comments

@bigfreeZhou
Copy link

my code in xml is

        <com.facebook.drawee.view.SimpleDraweeView
            android:layout_width="0dp"
            fresco:placeholderImage="@drawable/thisone_placeholder"
            fresco:actualImageScaleType="fitCenter"
            android:layout_height="wrap_content"
            fresco:viewAspectRatio="0.5625"
            android:layout_weight="1" />

thisone_placeholder_left is a jpg, when i use this, the memory increase fast.
and after i move it, it become normal.

@michalgr michalgr added the needs-details This issue or PR is currently not actionable as it misses details (e.g. for reproducing the problem) label Jan 13, 2016
@michalgr
Copy link
Contributor

Fresco does not do anything fancy about placeholder images - whatever you specify, it will be obtained via Resources.getDrawable (

builder.setPlaceholderImage(resources.getDrawable(placeholderId), placeholderScaleType);
).

Could you check whether the memory grows because the thisone_placeholder image is that big or because multiples instances of bitmaps are created (one per drawable) ? You can check that in heapdump.

@romulof
Copy link

romulof commented Feb 11, 2016

I confirm this.

I had a grid view with several images using a big JPEG as placeholder (for testing), and the app was crashing by memory shortage. I removed the placeholder and did the old way, checking if there's an image, else loading the placeholder as an actual image, and the leak stopped.

Here's Android Studio memory allocation analysis: 2016.02.10_21.04.zip

@tyronen
Copy link
Contributor

tyronen commented Feb 13, 2016

Placeholders are meant to be small, quickly-loaded images. If you need to use a large image there, you should use a low-res request instead.

@tyronen tyronen closed this as completed Feb 13, 2016
@romulof
Copy link

romulof commented Feb 13, 2016

Small or not, a leak is a leak.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-details This issue or PR is currently not actionable as it misses details (e.g. for reproducing the problem)
Projects
None yet
Development

No branches or pull requests

4 participants