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?