title: Ehcache not evicting cached entries
body: <p><strong>Main question is</strong> does ehcahce 2.6.2 do ANY eviction of expired elements based on ehcache configuration; or do I have to evict programatcially?</p>
  <p>After reading various parts of the documentation (<a href="http://ehcache.org/documentation/configuration/data-life" rel="nofollow noreferrer">data life</a> and <a href="http://ehcache.org/documentation/configuration/cache-size" rel="nofollow noreferrer">cache sizing</a>) we set the current configuration to use TTI/TTL and a CacheManager level maxBytesLocalHeap=1024m. After setting this I would expect ehcache to only use up to 1Gb of heap space for caching, but from testing (and prodcution) we consistently see the JVM heap get full (2GB in our case)</p>
  <p>Ehcache doesn't seem to honor the maxBytesLcoalHeap setting we set. Unless of course I (which is likely) dont' understand what this setting is actually doing.</p>
  <p>Some notes from our admins:</p>
  <blockquote>
  <p>During this test, the maxBytesLocalHeap value was 1024m which should have limited cache entries and references to 1GB total for the entire cache management pool.  The 8 individual caches were configured to use a portion of the 1024m.  The heap utilization climbed up in a steady fashion to the max heap size of 2GB.  Once there, garbage collection took longer and response times degraded.  The max heap size did not decrease after the test was over.  In fact, it is roughly 30 hours after the end of the test, I cleared all cache entries via the CacheManagement page and allowed the JVM to settle over night, and the heap is still committed to 2GB.  The use of the Old Generation space is flat with no room to spare.  The use of the Young Generation space came down some after I cleared cache entries, but that was only about 240MB and the committed space did not reduce.</p>
  </blockquote>
  <p>Thanks for your help and guidance!</p>
  <p><strong>Updated</strong></p>
  <p><em>ehcahce configuration</em></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;ehcache&gt;
  
   &lt;cache name=&quot;storeCache&quot; 
     maxElementsInMemory=&quot;2500&quot;
     memoryStoreEvictionPolicy=&quot;LFU&quot;
     eternal=&quot;false&quot;
     timeToLiveSeconds=&quot;86400&quot;
     statistics=&quot;true&quot;&gt; 
     &lt;persistence strategy=&quot;none&quot; /&gt;
  &lt;/cache&gt;
  
  &lt;cache name=&quot;courseCache&quot; 
     maxElementsInMemory=&quot;100000&quot;
     memoryStoreEvictionPolicy=&quot;LFU&quot;
     eternal=&quot;false&quot;
     timeToLiveSeconds=&quot;43200&quot;
     statistics=&quot;true&quot;&gt; 
     &lt;persistence strategy=&quot;none&quot; /&gt;
  &lt;/cache&gt;
  
  &lt;cache name=&quot;mtcIdCache&quot; 
     maxElementsInMemory=&quot;500000&quot;
     memoryStoreEvictionPolicy=&quot;LFU&quot;
     eternal=&quot;false&quot;
     timeToLiveSeconds=&quot;3600&quot;
     statistics=&quot;true&quot;&gt; 
     &lt;persistence strategy=&quot;none&quot; /&gt;
  &lt;/cache&gt;
  
  &lt;cache name=&quot;catentryCache&quot; 
     maxElementsInMemory=&quot;500000&quot;
     memoryStoreEvictionPolicy=&quot;LFU&quot;
     eternal=&quot;false&quot;
     timeToLiveSeconds=&quot;3600&quot;
     statistics=&quot;true&quot;&gt; 
     &lt;persistence strategy=&quot;none&quot; /&gt;
  &lt;/cache&gt;
  
  &lt;cache name=&quot;priceCache&quot; 
     maxElementsInMemory=&quot;500000&quot;
     memoryStoreEvictionPolicy=&quot;LFU&quot;
     eternal=&quot;false&quot;
     timeToLiveSeconds=&quot;300&quot;
     statistics=&quot;true&quot;&gt; 
     &lt;persistence strategy=&quot;none&quot; /&gt;
  &lt;/cache&gt;
  
  &lt;cache name=&quot;inventoryCache&quot; 
     maxElementsInMemory=&quot;500000&quot;
     memoryStoreEvictionPolicy=&quot;LFU&quot;
     eternal=&quot;false&quot;
     timeToLiveSeconds=&quot;300&quot;
     statistics=&quot;true&quot;&gt; 
     &lt;persistence strategy=&quot;none&quot; /&gt;
  &lt;/cache&gt;
  
  &lt;cache name=&quot;attributeCache&quot; 
     maxElementsInMemory=&quot;500000&quot;
     memoryStoreEvictionPolicy=&quot;LFU&quot;
     eternal=&quot;false&quot;
     timeToLiveSeconds=&quot;300&quot;
     statistics=&quot;true&quot;&gt; 
     &lt;persistence strategy=&quot;none&quot; /&gt;
  &lt;/cache&gt;
  
  &lt;cache name=&quot;partnerCache&quot; 
     maxElementsInMemory=&quot;10000&quot;
     memoryStoreEvictionPolicy=&quot;LFU&quot;
     eternal=&quot;false&quot;
     timeToLiveSeconds=&quot;86400&quot;
     statistics=&quot;true&quot;&gt; 
     &lt;persistence strategy=&quot;none&quot; /&gt;
  &lt;/cache&gt;
  &lt;/ehcache&gt;
  </code></pre>
  <p>** 2nd update **</p>
  <p><em>This is what our admin says about the heap utilization</em></p>
  <blockquote>
  <p>I have taken two memory snapshots for websvc01 JVM in relation to this endurance test.  They are available in dynaTrace for Monday 09/09 @ 10:10:59 and Tuesday 09/10 @ 10:46:48.  Both snapshots are Deep Memory Leak Analysis snapshots with capturing valued of string objects.</p>
  <p>During this test, the maxBytesLocalHeap value was 1024m which should have limited cache entries and references to 1GB total for the entire cache management pool.  The 8 individual caches were configured to use a portion of the 1024m.  The heap utilization climbed up in a steady fashion to the max heap size of 2GB.  Once there, garbage collection took longer and response times degraded.  The max heap size did not decrease after the test was over.  In fact, it is roughly 30 hours after the end of the test, I cleared all cache entries via the CacheManagement page and allowed the JVM to settle over night, and the heap is still committed to 2GB.  The use of the Old Generation space is flat with no room to spare.  The use of the Young Generation space came down some after I cleared cache entries, but that was only about 240MB and the committed space did not reduce.</p>
  </blockquote>
  <p><strong>Update:</strong></p>
  <p>Thanks for the responses I really appreciate it. I apologize for not updating this question for a while.</p>
  <p>Using DynaTrace we were able to determine it is a problem with Spring Integration. Specifically, the SimpleMessageStore seems to be holding onto objects and filling up!</p>
  <p><img src="https://i.stack.imgur.com/saLiY.png" alt="dynaTrace snapshot" /></p>
  <p>Reading the documentation it seems I should be using a <a href="http://docs.spring.io/spring-integration/docs/2.1.6.RELEASE/reference/html/messaging-routing-chapter.html#reaper" rel="nofollow noreferrer">MessageReaper</a>, but even after including this in the configuration I see the same issues. Should I be looking at the Capacity setting for the SimpleMessageStore instead?</p>