title: Java hashmaps and memory leaks
body: <p>I have a console Java application that needs some data from the database. As the application is running constantly, every 30 seconds, in order to lower the strain on the DB i'm using some sort of cache for the data.</p>
  
  <p>Because there isn't a large amount of the needed data in the database, i'm using singleton Hashmap as my cache. My cache class looks like this:</p>
  
  <pre><code>public class Cache extends Hashmap&lt;Integer, Hashmap&lt;Integer, ArrayList&lt;String&gt;&gt; {
  //some code
  }
  </code></pre>
  
  <p>Every 5 minutes system will refresh the cache by:</p>
  
  <p>1) calling "clear()" for the existing data
  2) filling the cache with new data from the db.</p>
  
  <p>Tell me, if i call the "clear()" for the structure i have ("nested" hashmaps) will Java clear all the data containd under my cache keys, or i'll end up with memory leaks?</p>