Skip to content Skip to sidebar Skip to footer

Carouselview Out Of Memory Exception

I am currently using a xamarin form version of Carousel View with ItemTemplate which have a list of templates e.g. public class TemplateSelector : DataTemplateSelector { privat

Solution 1:

Don't store all the images in the memory. You must have set the image source for your all image controls.It will show out of memory exception.

Create image cache for your image controls.

For example:

you can store your image in the file and memory cache u set,

We can defined the memory cache as

List<Bitmap> bitmapList;

set the bitmapList can store 4 images

when you move to the single CarouselPage just set the image source to your image control from the "bitmapList".

If you not find the image, get the image file from your file store cache and remove the useless image from the "bitmapList" keep the size is 4

If you use the same layout for the CarouselPage, don't need to create so many views(view1, view2,view3.....) please reuse these view.

Solution 2:

Open AndroidManifest.xml file located in Properties folder of Android Project.

Add android:largeHeap="true" in application tag. It will solve OOM issue.

Eg :

<?xml version="1.0" encoding="utf-8"?><manifestxmlns:android="http://schemas.android.com/apk/res/android"package="Sample.Sample"android:versionCode="1"android:versionName="1.0"android:installLocation="internalOnly"><applicationandroid:label="Sample"android:largeHeap="true"></application></manifest>

Post a Comment for "Carouselview Out Of Memory Exception"