1

I have several pages with images. All images are either static:

<Image Source="logo.png" HorizontalOptions="Center" WidthRequest="200" Aspect="AspectFit" />

or bound:

<Image Source="{Binding Image}" WidthRequest="40" HeightRequest="40" VerticalOptions="Center" />

I don't bind them through code.

After I move from one page to another several times, this exception appears

Xamarin caused by: java.lang.OutOfMemoryError: Failed to allocate a 9437196 byte allocation with 5765944 free bytes and 5MB until OOM at dalvik.system.VMRuntime.newNonMovableArray(Native Method) at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method) at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:700)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:535) at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:558) at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:588)

I tried calling GC.Collect() after page is closed, but doesn't work.

Rustam Ibragimov
  • 2,203
  • 5
  • 18
  • 30

1 Answers1

0
  • try to increase your project heap size.

Right click your Android Project > Properties > Android Options > Advanced > Java Max Heap Size > set 1G

  • try to call GC.Collect() before navigate to another page