title: Potential memory leak in Java, may this code lead to the memory leak?
body: <p>Let say I have a Java code, which constantly runs and every minute should get an array of really heavy objects and proceed them. The following code does the job:</p>
  
  <pre><code>while (true) {
  
      ArrayList&lt;HeavyObject&gt; objArr = this.getHeavyObject();
      drv.processObject(objArr);
  
      try {
          Thread.sleep(60000);
      } catch (InterruptedException e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>My question is:<br>
  May this code lead to the memory leak when executing <code>ArrayList&lt;HeavyObject&gt; objArr = this.getHeavyObject();</code> without assigning <code>objArr = null</code> before getting new batch of heavy objects?</p>
  
  <p>According to the «<a href="http://coderevisited.com/memory-leaks-in-java/" rel="nofollow">Memory leaks in Java</a>» article it's important to use assigning to <code>null</code> if I don't leave the scope of the variable (this code is a part of the <code>main()</code> and is alive until I exit the program).</p>
  
  <p>Can you clarify this aspect as applied to the code listed above?</p>