title: Java Garbage Collection on Stack-Based Arrays
body: <p>Suppose I have the following code:</p>
  
  <pre><code>public void process() {
      byte[] data = new byte[size]; 
      ... // code that uses the above data
      longProcess(); // a very long running process that does not use the data.
  }
  </code></pre>
  
  <p>Assuming that the data is not referenced anywhere else in the program, is the JVM smart enough to allow the data to be garbage collected while the long process is still running?   </p>
  
  <p>If not, will adding</p>
  
  <pre><code>data = null;
  </code></pre>
  
  <p>before the long process allow this to happen?</p>