title: OutOfMemoryException while loading large size images using glide
body: <p>So, I have been using this amazing library <a href="https://github.com/bumptech/glide" rel="noreferrer">Glide</a> for showing native images in my gallery app. I am using <code>ViewPager</code> with <code>FragmentStatePagerAdapter</code> to show full size images. The pager's off screen limit is <code>1</code> (default to save memory). I am using this code to load images into <code>ViewPager</code> in my fragment:</p>
  
  <pre><code>Glide.with(getActivity())
       .loadFromMediaStore(uri)
       .asBitmap()
       .signature(new MediaStoreSignature(mimeType, dateModified, 
       .into(mImageView);
  </code></pre>
  
  <p>Now, I am facing some issues here like:</p>
  
  <ol>
  <li>Images take quite some amount of time to load (if not cached). So, while user is scrolling through the viewpager blank screen is shown while image is loading which is what I want to avoid. Is there any way I can do this? Maybe by precaching images?</li>
  <li>Sometimes, while scrolling through large size images (mainly Camera photos) <strong>OOM Exception</strong> is thrown and user is left with blank screen as no image is loaded. This also happens when I am shifting from potrait to landscape mode. So, I tried to use methods like <code>atMost()</code> -- which degrade the quality of image further as images are already loaded in <code>RGB_565</code> and <code>approximate()</code> which is also causing OOM. How can I achieve maximum image quality without getting OOM exceptions?</li>
  </ol>
  
  <p>For the second issue, I was thinking to load lesser quality images for the off screen items and then enhance quality when they come on-screen. Is it possible?</p>
  
  <p>I have also tried to use <code>ARGB_8888</code> but the result was same: OOM exception.</p>