Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Android ViewPager with bitmaps causing memory leak

$
0
0

I implemented an activity in my Android project, to allow the user to flip through images by swiping left and right. I would have used Forms' CarouselPage, but I wanted the ability to pan/zoom the image, and couldn't do so with CarouselPage.

The problem is, the heap size is increasing every time I flip to a new image, but when I exit the activity, the heap size never decreases, which is obviously pointing to the problem being the bitmaps are not getting garbage collected.

For the ViewPager, I am using PagerAdapter to load/destroy the views. Even if I manually call bitmap.Dispose(), bitmap.Recycle(), GC.Collect(), Java.Lang.JavaSystem.Gc(), (I tried everything), the heap size never decreases. Eventually the heap gets to 192MB and causes an out-of-memory exception.

Does anyone have any experience with this issue? Is it related to Mono at all?


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>