title: OutOfMemory error on Android 6.0.1 devices after the second launch
body: <p>My project was working until I updated my S6 Edge to Android 6.0.1.</p>
  
  <p>The app crashes with an OutOfMemory error <strong>after</strong> the second launch.</p>
  
  <p>The application contains 2000+ images in the directory and I am using a timer to increment a counter and display them on an imageView. When onFinish()/onPause()/onDestroy() is called I am destroying/cancelling all the objects such as the timers, counter and imageView by setting them to null.</p>
  
  <p><strong>This is how I am fetching/printing the image to the imageView</strong></p>
  
  <pre><code>int resID = getResources().getIdentifier("animation"+i , "drawable", getPackageName());
      Drawable animationFrame = ContextCompat.getDrawable(this, resID);
      animationView.setImageDrawable(animationFrame);
      i++;
  </code></pre>
  
  <p>It runs on initial launch (even if I install the app using a generated APK). When I remove the app from the minimised applications, the application crashes after 2-3 seconds. I have checked the memory allocated and it is normal (up to 12MB) on the first run whereas on the second the memory allocated is 255MB.</p>
  
  <p><strong>onDestroy() method</strong>
  This includes <strong>ALL</strong> my variables initialised. My variables are initialised as private or with no access variable.</p>
  
  <pre><code>@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;
  
  }
  </code></pre>
  
  <p><em>Media is a MediaPlayer initialised as public and it plays a sound when counter(i) reaches a point</em></p>
  
  <p>I installed this on another device that runs Android 5.1.3 (not sure but it is 5.1 something).</p>
  
  <p>Is there is a known bug for OutOfMemory issues when application get minimised on Android 6.0.1?</p>
  
  <p>I am 100% sure that I did not make any changes before/after my phone updated to version 6.0.1</p>
  
  <p><strong>Memory Monitor on 1st Launch</strong><br>
  <a href="https://i.stack.imgur.com/CEWdA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CEWdA.png" alt="enter image description here"></a></p>
  
  <p><strong>Second Launch</strong><br>
  <a href="https://i.stack.imgur.com/b2u0r.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/b2u0r.png" alt="enter image description here"></a></p>
  
  <p><strong>Notes:</strong></p>
  
  <ol>
  <li>If the application is already installed on the device and I try to compile it using Android Studio, the crash occurs </li>
  <li>I have to uninstall/re-compile to manage to get the app working in the first go</li>
  <li>I get the same error when I try to run my project on a Genymotion Android 6.0 device, but not on an Android 5.1 genymotion virtual device</li>
  </ol>