[Android] Move the ThumbnailerManager into the MainActivity

Ludovic Fauvet etix at videolan.org
Sat Sep 29 13:27:20 CEST 2012


On Sat, Sep 29, 2012 at 11:29 AM, XilasZ <xilasz at gmail.com> wrote:
>
>> Furthermore the ThumbnailerManager is now a singleton so it can be
>> accessed indifferently from the MainActivity or the VideoListFragment.
>
>
> I'm don't think bringing a singleton here is a good idea, Android can decide
> to destroy the MainActivity or the VideoListFragment when they are not
> displayed.
> - Because the ThumbnailManager hold a reference to them, they won't be
> garbage collected => memory leak
> - when a new MainActivity/VideoListFragment will try to use
> ThumbnailManager, ThumbnailManager will try to use an old invalid
> MainActivity/VideoListFragment => it will surely crash
>
> That's why i removed context singletons or singletons which holds contexts
> back in frebruary (around 2012/02/18 & 2012/02/19).
>
> see here :
> http://android-developers.blogspot.fr/2009/01/avoiding-memory-leaks.html

Indeed, what I did here is wrong.

-- 
Ludovic Fauvet


More information about the Android mailing list