title: Android ViewPager - OutOfMemory Exception using Glide (on phones and on TV)
body: <p>I'm using <code>ViewPager</code> in my app for showing pictures (from camera, etc. so it can be large pictures). Also I'm using <code>Glide library</code> for loading pictures from <code>Uri</code> to <code>ImageView</code>. This is my <code>PagerAdapter</code>:</p>
  
  <pre><code>public class GalleryPagerAdapter extends PagerAdapter {
  
     private List&lt;FileMetaData&gt; mPhotos = null;
     private Context _context;
     private LayoutInflater _inflater;
  
     public GalleryPagerAdapter(Context context, List&lt;FileMetaData&gt; files) {
        _context = context;
        mPhotos = files;
        _inflater = (LayoutInflater) _context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
     }
  
     @Override
     public boolean isViewFromObject(View view, Object object) {
        return view == ((ImageView) object);
     }
  
     @Override
     public int getCount() {
        return mPhotos.size();
     }
  
     @Override
     public Object instantiateItem(ViewGroup container, final int position) {
        View itemView = _inflater.inflate(R.layout.photo_pager_item, container, false);
        container.addView(itemView);
  
        ImageView imageView = (ImageView) itemView.findViewById(R.id.imageViewPhotoDetail);
  
        Glide.with(_context).load(mPhotos.get(position).getUri()).placeholder(R.drawable.placeholder_image)
              /*.skipMemoryCache(true).*/.diskCacheStrategy(DiskCacheStrategy.NONE).into(imageView);
  
        return itemView;
     }
  
     @Override
     public void destroyItem(ViewGroup container, int position, Object object) {
        ImageView i = (ImageView) object;
        container.removeView(i);
     }
  }
  </code></pre>
  
  <p>Layout <code>photo_pager_item</code> is simple:</p>
  
  <pre><code>&lt;ImageView xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/imageViewPhotoDetail"
      android:layout_width="match_parent"
      android:layout_height="match_parent" /&gt;
  </code></pre>
  
  <p>And <code>setOffscreenPageLimit</code> is set to 1 (by default). My problem is that I'm getting <code>OutOfMemory Exception</code>. But I don't know how to solve it. What should I change? How can I recycle images loaded by Glide? And I need to make it work also on TV (big screen).</p>