An uncaught Exception occurred on "main" thread. java.lang.OutOfMemoryError: Failed to allocate a 51121164 byte allocation with 16766592 free bytes and 40MB until OOM

plugins

#1

When i try to load so many data image with listView and plugin (nativescript-fresco for optimize load image), in this case I have an error like this :

An uncaught Exception occurred on "main" thread.
java.lang.OutOfMemoryError: Failed to allocate a 51121164 byte allocation with 16766592 free bytes and 40MB until OOM
	at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
	at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
	at android.graphics.BitmapFactory.decodeStreamInternal(BitmapFactory.java:726)
	at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:702)
	at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:474)
	at org.nativescript.widgets.image.Fetcher.decodeSampledBitmapFromFile(Fetcher.java:409)
	at org.nativescript.widgets.image.Fetcher.processBitmap(Fetcher.java:256)
	at org.nativescript.widgets.image.Worker.loadImage(Worker.java:114)
	at org.nativescript.widgets.ImageView.loadImage(ImageView.java:191)
	at org.nativescript.widgets.ImageView.onAttachedToWindow(ImageView.java:57) .........
............................................................ etc.

This problem arises when i use samsung J7 (android N)
I need help, What is the solution for this case?

Thank you.


#2

Please share some code about your ListView implementation. There is probably something you’re missing regarding garbage collection.

If you work with a lot of images, please make sure you use resized images and JPG format for better performance.