title: heap size usage using "javaw.exe" vs "java.exe"
body: <p>Below is the program,</p>
  
  <pre><code>public class Dummy {
  
      public static void main(String[] args) throws Exception {
          final int LENGTH = Integer.MAX_VALUE / 8;
          Object[] values = new Object[LENGTH];
          int count = 0;
          for (int i = 0; i &lt; Integer.MAX_VALUE; i++) {
              Object o = new Object();
              int hashCode = o.hashCode();
              if (hashCode &gt; LENGTH)
                  continue;
              if (values[hashCode] != null) {
                  System.out.println("found after " + count + ": " + values[hashCode] + " same hashcode as " + o);
                  System.out.println(values[hashCode] == o);
                  System.exit(0);
              } else {
                  System.out.println(hashCode);
                  values[hashCode] = o;
                  count++;
              }
          }
      }
  }
  </code></pre>
  
  <p>when launched via eclipse(thru 64 bit <code>javaw.exe</code>) has the heap usage that goes upto below shown approximate value(max) consistently and battery goes down in minutes,</p>
  
  <h2><img src="https://i.stack.imgur.com/WJMS9.png" alt="enter image description here"></h2>
  
  <p>and then shows the below exception:</p>
  
  <pre><code>Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit exceeded
  </code></pre>
  
  <p>On same machine, the same program when launched using 64-bit <code>java.exe</code> from command line, new hashcode clashes with previous hashcode consistently after creating 22985 objects in <code>for-loop</code> with "private working set" value of 1GB(max).</p>
  
  <pre><code>:
  23206321
  39915397
  found after 22985: java.lang.Object@f2eb847 same hashcode as java.lang.Object@f2eb847
  false
  </code></pre>
  
  <p>Without concentrating much on code logic, I would like to understand,</p>
  
  <p>1) Why the difference in heap usage comparing both approaches? Because there is no tuning done for either approach.</p>
  
  <p>2)
  How do i control heap usage  parameters before starting the program either via eclipse(<code>javaw.exe</code>) or via command line(<code>java.exe</code>)? Please help me!!!</p>
  
  <p>Note: am working with java 1.6</p>