title: Prevent OOM while displaying full page Images
body: <p>I recently implemented a tutorial for my app. This tutorial is done through a viewpager with full page images. There are 10 images that are approx  170kb. I have had no issues with memory while testing but I see error reports coming in with OOM exceptions. I use a FragmentStatePagerAdapter and recycle each bitmap manually when the fragment is destroyed.</p>
  
  <pre><code>  private class TutorialPageAdapter extends FragmentStatePagerAdapter {
  
      private int[] tutorialImages;
  
      public TutorialPageAdapter(FragmentManager fm, int [] tutorialImages) {
          super(fm);
          this.tutorialImages = tutorialImages;
      }
  
      @Override
      public Fragment getItem(int i) {
          Bundle b = new Bundle();
          b.putInt(C.BUNDLE_TUTORIAL_IMAGE, tutorialImages[i]);
          b.putBoolean(TutorialPageFragment.FINAL_TUTORIAL_SCREEN, i == getCount()-1 &amp;&amp; !singleTutorial);
          TutorialPageFragment frag = new TutorialPageFragment();
          frag.attachListener(TutorialFragment.this);
          frag.setArguments(b);
          return frag;
      }
  
      @Override
      public int getCount() {
          return tutorialImages.length;
      }
  }
  </code></pre>
  
  <p>Then the fragments that are in the view pager </p>
  
  <pre><code>   @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
      View v = inflater.inflate(R.layout.fragment_tutorial_page, container, false);
      ButterKnife.inject(this, v);
      Bitmap bm = BitmapFactory.decodeResource(getResources(), getArguments().getInt(C.BUNDLE_TUTORIAL_IMAGE));
      tutorialImage.setImageBitmap(bm);
      if (getArguments().getBoolean(FINAL_TUTORIAL_SCREEN, false)) {
          finishTutorial.setVisibility(View.VISIBLE);
      }
      if (prefs.getBoolean(C.PREF_TUTORIAL_SHOW, false)) {
          _setupSwipeClose();
      }
      return v;
  }
  
  @Override
  public void onDestroyView() {
      super.onDestroyView();
      Drawable drawable = tutorialImage.getDrawable();
      if (drawable != null &amp;&amp; drawable instanceof BitmapDrawable) {
          ((BitmapDrawable) drawable).getBitmap().recycle();
      }
  }
  </code></pre>
  
  <p>Any tips on how else I could prevent OOM exceptions?</p>