title: Android Volley give me an outOfMemory exception
body: <p>I am using volley to showing images in horizontal swipe view from the server, but my images are quite large that's way i am getting an exception of out of memory</p>
  
  <p>Below is my volley class:</p>
  
  <pre><code>public class Volley{
  
  private RequestQueue mRequestQueue;
  private ImageLoader mImageLoader;
  
  public Volley(Context ctx) {
      Log.v("Volley", "Volley onCreate");
      mRequestQueue = com.android.volley.toolbox.Volley.newRequestQueue(ctx);
  
      final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
      final int cacheSize = maxMemory / 8;
  
      ImageLoader.ImageCache imageCache = new ImageLoader.ImageCache() {
          LruCache&lt;String, Bitmap&gt; imageCache = new LruCache&lt;String, Bitmap&gt;(cacheSize);
  
          @Override
          public void putBitmap(String key, Bitmap value) {
              imageCache.put(key, value);
          }
  
          @Override
          public Bitmap getBitmap(String key) {
              return imageCache.get(key);
          }
      };
  
      mImageLoader = new ImageLoader(mRequestQueue, imageCache);
  
  }
  
  public void clear(Context ctx) {
      mRequestQueue.cancelAll(ctx);
      mImageLoader = null;
      mRequestQueue = null;
  }
  
  public RequestQueue getRequestQueue() {
      return mRequestQueue;
  }
  
  public ImageLoader getImageLoader() {
      return mImageLoader;
  }}
  </code></pre>
  
  <p>Image loader code:</p>
  
  <pre><code>image.setImageUrl(imagePhoto.url, getVolley(getContext()).getImageLoader());
  
  public Volley getVolley(Context ctx) {
      if(mVolley == null) {
          mVolley = new Volley(getContext());
      }
      return mVolley;
  }
  </code></pre>
  
  <h2>Exception:</h2>
  
  <pre><code>&gt; 06-10 22:14:27.462: E/AndroidRuntime(10060): FATAL EXCEPTION: Thread-29479
  06-10 22:14:27.462: E/AndroidRuntime(10060): java.lang.OutOfMemoryError
  06-10 22:14:27.462: E/AndroidRuntime(10060):    at com.android.volley.toolbox.ByteArrayPool.getBuf(ByteArrayPool.java:101)
  06-10 22:14:27.462: E/AndroidRuntime(10060):    at com.android.volley.toolbox.PoolingByteArrayOutputStream.&lt;init&gt;(PoolingByteArrayOutputStream.java:53)
  06-10 22:14:27.462: E/AndroidRuntime(10060):    at com.android.volley.toolbox.BasicNetwork.entityToBytes(BasicNetwork.java:202)
  06-10 22:14:27.462: E/AndroidRuntime(10060):    at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:104)
  06-10 22:14:27.462: E/AndroidRuntime(10060):    at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:105)
  </code></pre>