title: android animatorset memory management, freeing up memory from imageview
body: <p>I have a repeating AnimatorSet that uses a sequence of full frame images on several different activities.  I'm getting an out of memory exception as it seems that the imageviews are taking up too much memory.</p>
  
  <p>Originally the activities in the background still had their animations running in a loop taking up memory.  I tried remedying by creating and ending animations on pause/resume so that memory from animations in the non-foreground views are reclaimed but I think I need to do more to clear out the imageviews from memory as well.</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_face_o_matic_start);
          getActionBar().hide();
  
  }
  
  @Override
  protected void onResume() {
      super.onResume();
      createAnimations();
  }
  
  
  @Override
  protected void onPause() {
      super.onPause();
      this.mAnimatorSet.removeAllListeners();
      this.mAnimatorSet.end();
              //TODO: clear and free up the memory from the image views somehow
              // this is the part I need help with I think
  
  }
  
  protected ObjectAnimator getGlowAnimation(View v, int duration){
      ObjectAnimator animation = ObjectAnimator.ofFloat(v, "alpha", 0f, 1f);
      animation.setDuration(duration);
      animation.setRepeatCount(1);
      animation.setRepeatMode(Animation.REVERSE);
      return animation;
  }
  
  public void createAnimations(){
  
      //TODO: destroy these imageviews to reclaim memory on pause
              // originally had them in on create but the imageviews continued to
              // take up memory when the activity went into the background
      /*start animations */
  
      final ImageView bg1 = (ImageView) findViewById(R.id.bg_face_o_matic_1);
      final ImageView bg2 = (ImageView) findViewById(R.id.bg_face_o_matic_2);
      final ImageView bg3 = (ImageView) findViewById(R.id.bg_face_o_matic_3);
      final ImageView bg4 = (ImageView) findViewById(R.id.bg_face_o_matic_4);
      final ImageView bg5 = (ImageView) findViewById(R.id.bg_face_o_matic_5);
      final ImageView bg6 = (ImageView) findViewById(R.id.bg_face_o_matic_6);
  
      ObjectAnimator anim1 = getGlowAnimation(bg1, 400);
      ObjectAnimator anim2 = getGlowAnimation(bg2, 400);      
      ObjectAnimator anim3 = getGlowAnimation(bg3, 400);
      ObjectAnimator anim4 = getGlowAnimation(bg4, 400);
      ObjectAnimator anim5 = getGlowAnimation(bg5, 400);
      ObjectAnimator anim6 = getGlowAnimation(bg6, 400);
  
      List&lt;Animator&gt; animations = new ArrayList&lt;Animator&gt;(Arrays.asList(anim1, anim2, anim3, anim4, anim5, anim6));
      mAnimatorSet.playSequentially(animations);
              //loop the animator set
      mAnimatorSet.addListener(new AnimatorListenerAdapter(){
  
          @Override
          public void onAnimationEnd(Animator animation) {
              super.onAnimationEnd(animation);
              mAnimatorSet.start();
  
          }
  
      });
  
      mAnimatorSet.start();
      /*end animations */
  }
  </code></pre>