title: java persistance memory leaks
body: <p>I have 1M rows in a mysql table and I am java persistence api when I execute following code then I get java heap error:</p>
  
  <pre><code>int counter = 0;
  while (counter &lt; 1000000) {
     java.util.Collection&lt;MyEntityClass&gt; data = myQuery.setFirstResult(counter)
         .setMaxResults(1000).getResultList();
     for(MyEntityClass obj : data){
         System.out.println(obj);
     }
     counter += 1000;
  }
  </code></pre>