title: How can I correctly configure limited cache for the android universal image loader?
body: <p>I'm using the <a href="https://github.com/nostra13/Android-Universal-Image-Loader" rel="nofollow">"Android universal image loader library (v 1.9.1)"</a> and I'm trying to limit the amount of (disc) cache being used by using this line in a config builder:</p>
  
  <pre><code>.discCache(new TotalSizeLimitedDiscCache(cacheDir, 25 * 1024 * 1024))
  </code></pre>
  
  <p>I might be doing something really stupid here, but this was supposed to limit my cache to 25MB and when I look at the current App info I'm already at 45+ MB, so it doesn't seem to be working.</p>
  
  <p>Have I missed something? </p>
  
  <p><strong>added suspicion</strong>: what if the cache-number also includes the 'memorycache' that is set to true? I working under the assumption this is only a cache as far as the <code>imageLoader</code> is concerned, and from an application/os point of view just another thing using memory. if it isn't, it might explain the numbers?</p>
  
  <p>Complete code for initializing :</p>
  
  <pre><code>private void initImageLoader() {
      DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
          .cacheInMemory(true)
          .cacheOnDisc(true)
          .build();    
  
       File cacheDir = StorageUtils.getCacheDirectory(getApplicationContext());
       cacheDir.mkdirs(); 
  
  
      ImageLoaderConfiguration config = new 
          ImageLoaderConfiguration.Builder(getApplicationContext())
          .defaultDisplayImageOptions(defaultOptions)
          .discCache(new TotalSizeLimitedDiscCache(cacheDir, 25 * 1024 * 1024))
          .build();
  
      ImageLoader.getInstance().init(config);             
  }
  </code></pre>
  
  <p>And for calling the code (showing <code>imageUrl</code> in <code>imageView</code>)</p>
  
  <pre><code>ImageLoader.getInstance().displayImage(imageUrl, imageView); 
  </code></pre>