How to avoid memory leaks in frame animation?

I created a simple test application with one action. Activity contains a frame animation. The total size of the images in the frame animation (riffle_forward_anim) is about 1 MB. Here is the code I use to download the animation:

public class MainScreen extends Activity {
/** Called when the activity is first created. */

Private ImageView imgForward; Private ImageView imgBack;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    imgForward = (ImageView) findViewById(R.id.imgForward);

    imgForward.setBackgroundResource(R.anim.riffle_forward_anim);

}

@Override
public void onPause(){
 super.onPause();
 AnimationDrawable anim = (AnimationDrawable) imgForward.getBackground();



 int count = anim.getNumberOfFrames();
 for(int i=0;i<count;i++){
  anim.getFrame(i).setCallback(null);
 }

 imgForward.getBackground().setCallback(null);

 imgForward = null;
}

}

As you can see, I am trying to free memory in the onPause () method. Yes, I read http://developer.android.com/resources/articles/avoiding-memory-leaks.html

, protrait/landscape. , , . , , realisng. - , ?

+3

Source: https://habr.com/ru/post/1729291/