Xamarin Formats: Image Slider: CarouselPage - Out of Memory

I am using CarouselPage to show a bunch of images and I want the user to be able to drag through them. CarouselPage will seem like the best option, but now that I use it, I'm not sure anymore.

My emulator is running out of memory and when I test it on a real mobile device it crashes. There are only 56 images to show, but CarouselPage cannot handle it. A carousel page is suitable for such a task, if yes: how can I make it faster.

This is the code I am using to add PhotoPages.

foreach (Photo p in Gallery.Photos) {
        // Get the photo path on device.
        string path = DataAccessor.GetPhotoPath (p);
        PhotoPage page= new PhotoPage (path);
        Children.Add (page);
}

      

PhotoPage is just an ImageView inside a ContentPage.

So, other than adding fewer children to the carousel, is there a way to use the carousel page as an image slider without memory exceptions or frozen screens? Or is there another solution to create ImageSlider without using CarouselPage.

+3


source to share


1 answer


I also faced a similar problem. What I have done so far is added, let's say 5 pages, when I go to the next page, remove the first child from the CarouselPage and add another child to the end of the CarouselPage. If you can limit the number of children (ex: 5) at a time, you can avoid this exception.

Android may appear adding below line in manifest.



    <application android:largeHeap="true"></application>

      

+3


source







All Articles