-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
SimpleDraweeView did not recycled in RecyclerView #414
Comments
I also experience this. Can be also reproduced on rotation. This is my code: public class PhotoAdapter extends BaseRecyclerAdapter<PhotoAdapter.ViewHolder>
} |
One thing that is wrong with your code is that you are setting both the controller and the uri. You should only do one of those.
Note, for this experiment you won't see the images, but that's expected. Please let me know if you are still observing the leaks after removing those two lines and we can continue from there. Also, how many instances of SimpleDraweeView are there? Easy way to check would be to just log the reference of |
Thank you for your answer. I somehow missed the last line during refactoring. By removing these lines the leeks stopped (or at least where very small). Are these the logs you are looking for? (photo.toString())
Next, I simplified my code to private void setupImage(SimpleDraweeView photo, Uri uri)
{
photo.setImageURI(uri);
} And the leaks and oom crashes still occur on rotate. And bdw pozdrav iz Zagreba. 😃 |
Some more information. The memory leak occurred on my 5.1.1 Android device. Memory usage is quite excessive. Starts with 46MB for 5 pictures and gets to 59MB on rotate, then 76 on next until OOM. The same code and the same pictures on my 4.3 tablet don't have the leak as I can see. It starts with 23MB then 25, 27 then at around 35 it goes down. So it seems the problem is related to Android version maybe? This is my drawee view (row_photo.xml) just for reference:
|
and here is the log if it helps
|
Hmm, there may be some issues with Drawee + RecyclerView combination. If you are familiar with MAT, it would be very helpful to see what is referencing the leaked Bitmaps. We will also investigate on our own, but since you are able to reproduce the issue, any help would be greatly appreciated! As for the Android version, Fresco on Lollipop keeps the bitmaps on the Java heap and that's why you are getting OOMs. That doesn't mean that the leak is not happening on older Android versions where we keep bitmaps in the native memory. The leak may still be there, but it won't be detected by the Java VM. |
I'm willing to help but I'm not familiar with MAT. Can you link it? Also is this of any help to you? https://github.com/square/leakcanary I have made some new discoveries, and maybe this will seem a huge newbie mistake to you, but after moving
from the beginning of every activity to an application class, the leak seams to be gone or at very least harder to reproduce. If indeed this is the intended use, maybe it would be best to highlight it a bit more. If it is a mistake from my part sorry for wasting your time. |
Oh yes, you should only call Fresco.initialize once, near the application startup. Doing it in each Activity is wrong. We shall update the documentation to reflect this more clearly. Also, this might be of interest: |
Thank you. |
@r1m Thank you VERY much... That made my OOMs go away. |
@mheras There is no other option - you have to pass |
The app author shouldn't have to initialize Fresco just because you are using it. However, if they happen to be using Fresco on their own, your library has to reflect their config. You should offer two initialization methods: one that takes an ImagePipelineConfig object, and one that doesn't. Only the second should call Fresco.initialize; the first should assume the app will do it. |
@tyronen i had do two initialization methods,but it's also oom |
Seems like the answer here is a major discrepancy with the documentation (http://frescolib.org/docs/using-controllerbuilder.html) where it clearly says
|
I have the same experience, and find that is the image url witch you have request from server is too big to your device, you should call ImageRequest and setResizeOptions to resize the image. @06peng |
I am using SimpleDraweeView to load image in RecyclerView,At first the memory is 40M,When I scrolling the RecyclerView slowly,the memory increase to 200M and didn't recycled.
Is there a method can manual recycled the memory? Thanks!
The text was updated successfully, but these errors were encountered: