title: Java Heap Memory issue when loading files in HashMap
body: <p>I am using LRUMap from org.apache.commons.collections4.map.LRUMap to load my classifiers on demand and keep few in cache. I kept my cache size 20 but I have 400 classifiers on disk. Based on LRU cache policy classifiers will swap in and swap out from LRUMap. But After few swap in and swap out my system memory increase and gives java.lang.OutOfMemoryError: Java heap space OR java.lang.OutOfMemoryError: GC overhead limit exceeded ERROR. </p>
  
  <p>I have tried to Increase memory from 6 GB to 12 GB but then also it will go out of memory. But when I load all the classifiers at the time of application start, In that case my application will work fine. </p>
  
  <pre><code>public class Cache
  {
    private static LRUMap&lt;Integer, Classifier&gt; lruMap = new LRUMap&lt;&gt;(20);
  
   public Classifier getClassifiers() {
      for (int i = 0; i &lt; 10; i++)
      {
        if (lruMap.containsKey(i))
        {
          return lruMap.get(i);
        }
       else
       {
         try (ObjectInputStream ins = new ObjectInputStream(new FileInputStream(filePath)))
        {
           classifier = (Classifier) ins.readObject();
           lruMap.put(i, classifier);
           return classifier;
         }
        catch (ClassNotFoundException | IOException e)
        {
           // some message;
        }
      }
    }
  }
  </code></pre>
  
  <p>Why it goes OutOfMemory?</p>