title: Why does an empty Java program consume memory?
body: <p>I'm exploring memory usage in Java to understand why my program leaks memory. After stripping off code in my main while loop, I still get an increase of memory usage over time. Pondering the memory usage of an empty program:</p>
  
  <pre><code>class Nothing
  {    public static void main(String[] args)
       {    while(true);    }
  }
  </code></pre>
  
  <p>I still saw an increase of memory: </p>
  
  <p><a href="https://i.stack.imgur.com/76iaK.png" rel="noreferrer"><img src="https://i.stack.imgur.com/76iaK.png" alt="Image description here"></a></p>
  
  <p>So my question is: Why is there still a saw tooth pattern? Why when the GC runs does it not save all the memory (each time the gc runs (the valleys) the used memory increases by 10-20Kb (compared to the previous valley))?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>java version "1.6.0_29"</p>
  
  <p>Java(TM) SE Runtime Environment (build 1.6.0_29-b11)</p>
  
  <p>Java HotSpot(TM) Client VM (build 20.4-b02, mixed mode, sharing)</p>
  
  <p>OS: Windows 7 Enterprise-32 bit</p>