Throwing OutOfMemoryError


Hi my application also have 6 screens. When I change the screen more than once in the application, I get the error that an application has stopped. I have run ADB Logcat and I have recorded the records as follows, how can I fix this error?
(I have many blocks in the application so I can’t share the screenshot.)

3876 6001 I art : Forcing collection of SoftReferences for 4MB allocation
3876 6001 I art : Starting a blocking GC Alloc
3876 6001 I art : Clamp target GC heap from 139MB to 128MB
3876 6001 I art : Alloc concurrent mark sweep GC freed 3(72B) AllocSpace objects, 0(0B) LOS objects, 3% free, 123MB/128MB, paused 2.590ms total 88.259ms
3876 6001 W art : Throwing OutOfMemoryError "Failed to allocate a 5172812 byte allocation tes and 4MB until OOM"
3876 6001 E AndroidRuntime: FATAL EXCEPTION: Thread-97
3876 6001 E AndroidRuntime: Process: com.xxxxxxx, PID: 3876
3876 6001 E AndroidRuntime: java.lang.OutOfMemoryError: Failed to allocate a 5172812 byte allocation with 4891184 free bytes and 4MB until OOM
3876 6001 E AndroidRuntime: at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
3876 6001 E AndroidRuntime: at Method)
3876 6001 E AndroidRuntime: at
3876 6001 E AndroidRuntime: at
3876 6001 E AndroidRuntime: at
3876 6001 E AndroidRuntime: at
3876 6001 E AndroidRuntime: at$


Try this:


see tip 1 and 2


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.


You need to properly handle changing screens

CC @Taifun


@Taifun @Ken

I’m already using this method. I will try to change the size of the picture, thank you.



I have a question about this topic.
I try to follow all Tips and Tricks from Taifun.

There is a quote from Italo

I do not know if I understand correctly.
I use also arrangements as “screens”, there is one screen, invisible at initialized, that contains many images.

Is it now better not to set pictures but only when it becomes visible?
Arrangement visible
Set image to…

Or do I misunderstand this?

Kind regards


By the great @italo :sunglasses:

First, you need to understand that the file size of an image is not the amount of memory it uses when it’s being displayed. The file size is the compressed size, much like a zip or rar file. When viewed, the image needs to be decompressed.
For example, if your image says its file size is 100 kb, and its dimensions are 1024 x 768, 32 bit color, then that image uses over 3 mb of RAM (not 100 kb!) when you show it on the screen. ((1024 * 768 ) * 32) / 8 = 3,145,728 kb (3 mb)
Now, this is a mistake most people make when using arrangements as “virtual screens”: They set different image components with their images loaded but hidden, instead of having only one image component and changing the picture according to the user’s selection or app events, not knowing that apparently the hidden image components are also using the ram, (yes, even though they are invisible!).


Hello Peter,
Thanks for your response.
Yes, I know that and I try to pay attention. :wink:

My question is aiming for something else.
Is it better to set images inside arrangements inside the block editor only when the arrangement becomes visible or make it no difference…



Here is your answer. It was in the quote from Italo.