title: How to make List of type Object eligible for garbage collection
body: <p>I have a</p>
  
  <pre><code>List&lt;Animal&gt; results= new List&lt;Animal&gt;();
  </code></pre>
  
  <p>Inside Animal Class i have getter setter for value field which is map:</p>
  
  <pre><code>    public class Animal
          {
           private final HashMap&lt;String,Object&gt; value; 
          }
  
      Now I am iterating over result
  
      for(int i=0;i&lt;results.size();i++){
      {
        HashMap&lt;String, Object&gt; value= result.get(i).getValue();
         String a =value.get("test")
    }
  }
  </code></pre>
  
  <p>How can I make the  the entire List and all Animal Objects inside it eligible for garbage collection</p>