OutOfMemory error on Android 6.0.1 devices after second launch

My project worked until I upgraded my S6 Edge to Android 6.0.1.

Application crashes with OutOfMemory error after the second launch.

The application contains 2000+ images in the catalog, and I use a timer to increase the counter and display them in imageView. When onFinish () / onPause () / onDestroy () is called, I destroy / cancel all objects like timers, count and imageView, setting them to null.

This is how I select / print an image in imageView

int resID = getResources().getIdentifier("animation"+i , "drawable", getPackageName()); Drawable animationFrame = ContextCompat.getDrawable(this, resID); animationView.setImageDrawable(animationFrame); i++; 

It starts when it first starts (even if I install the application using the generated APK). When I remove an application from minimized applications, it crashes after 2-3 seconds. I checked the allocated memory, and this is normal (up to 12 MB) on the first start, while on the second the allocated memory is 255 MB.

OnDestroy () method This includes ALL of my initialized variables. My variables are initialized as private or without an access variable.

 @Override protected void onDestroy() { super.onDestroy(); pauseAnimation(); animationView.setImageDrawable(null); animationView = null; justAnimation = null; buttonSign = null; i = 0; media.stop(); media = null; deathRateEU = 0; deathRateUK = 0; labelNumber = null; labelNumberUK = null; buttonSign = null; loadingEU = null; loadingUK = null; } 

Media is a MediaPlayer initialized as open, and it plays a sound when counter (i) reaches a point

I installed this on another device that is running Android 5.1.3 (not sure, but this is something 5.1).

Is there a known bug for OutOfMemory problems when the application is minimized to Android 6.0.1?

I am 100% sure that I did not make any changes before / after my phone was updated to version 6.0.1

First time memory monitor
enter image description here

Second launch
enter image description here

Notes:

  1. If the application is already installed on the device and I try to compile it using Android Studio, it crashes
  2. I need to uninstall / recompile for the application to work the first time
  3. I get the same error when trying to run my project on a Genymotion Android 6.0 device, but not on an Android 5.1 genymotion virtual device
+11
android android-6.0-marshmallow out-of-memory android-6.0.1-marshmallow
source share
3 answers

Instead, you can use picasso () to manage your images .... at least as a quick experiment to see if it behaves differently.

0
source share
0
source share

I would recommend you use the Glide library to efficiently download large images.
You can also check out this article on how to efficiently load bitmap images.

0
source share

All Articles