Frage

I've managed to convert Universal Image Loader to use it with xamarin.android. Everything works ok untill I show a big list of images - OOM exception started to appear. I've tried every possible combination of cache/image settings suggested at UIL site or at stackoverflow answers - none seems to work in my case.

I use Android Debug Monitor to see what's going on. And from what I can tell there is a memory leak caused by UIL. I can say that because if don't use image loader to load bitmaps there is no leak. But I'm starting to think that the reason for this leak is not directly caused by UIL cause it is there regardless what configuration I choose.

So my question is what else could it be ?

War es hilfreich?

Lösung

So after debugging and googling I've found that Xamarin Garbage Collection Article. Conclusion is that bitmaps that UIL loaded (with or without cache) couldn't be released because there was a relationship between the managed Bitmap (Mono/.net) and framework Bitmap (Java) instances. To break that relationship I call bitmap.Dispose() in OnLoadingComplete in my implementation of IImageLoadingListener.

    public void OnLoadingComplete(string p0, View p1, Bitmap p2)
    {
        var spinner = ((View)p1.Parent).FindViewById<ProgressBar>(Resource.Id.loading);
        spinner.Visibility = ViewStates.Gone;
        p2.Dispose();
    }
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top