title: What set the value of JVM parameter MaxNewSize? Ergonomics?
body: <p>My server info:</p>
  
  <ul>
  <li>CPU:Intel Xeon E5-2630 </li>
  <li>Memory:65970676K</li>
  <li>OS:Centos 6.4</li>
  <li>kernel:3.8.0</li>
  <li>jdk: HotSpot JDK 1.6.0.27</li>
  </ul>
  
  <p>I use <code>jmap -heap pid</code> to print heap info:</p>
  
  <pre><code>Heap Configuration:
  MinHeapFreeRatio = 40
  MaxHeapFreeRatio = 70
  MaxHeapSize      = 21474836480 (20480.0MB)
  NewSize          = 21757952 (20.75MB)
  MaxNewSize       = 174456832 
  OldSize          = 65404928 (62.375MB)
  NewRatio         = 7
   SurvivorRatio    = 8
  PermSize         = 268435456 (256.0MB)
  MaxPermSize      = 268435456 (256.0MB)
  </code></pre>
  
  <p>And following are the JVM args I defined to run my application:</p>
  
  <pre><code> -verbose:gc  -XX:+UseMembar -XX:+PrintGCDetails - 
   XX:+PrintGCTimeStamps  -XX:+DisableExplicitGC - 
   XX:+CMSClassUnloadingEnabled
  -XX:-OmitStackTraceInFastThrow  -Xloggc:/export/logs/gc.log 
  -XX:PermSize=256m -XX:MaxPermSize=256m -Xms6G  -Xmx12G
  </code></pre>
  
  <p>I don't set <code>MaxNewSize</code>, I tried to use <code>java -XX:+PrintFlagsFinal</code> to print all of the JVM args and found <code>MaxNewSize</code> is a very very big number: <code>18446744073709486080</code>. I think Ergonomics may have set <code>MaxNewSize</code> to <code>174456832</code> for me. However, I have another server, which has the same hardware and software, where <code>MaxNewSize</code> is <code>392560640</code> while other heap parameters are the same.</p>
  
  <h2>What's the basis for Ergonomics setting the value of <code>MaxNewSize</code>? Can I see this in the source code of Ergonomics?</h2>
  
  <p>I think I found where the value of MaxNewSize is set:Arguments.cpp (hotspot\src\share\vm\runtime)</p>
  
  <pre><code>if (CMSUseOldDefaults) {  // old defaults: "old" as of 6.0
    if FLAG_IS_DEFAULT(CMSYoungGenPerWorker) {
      FLAG_SET_ERGO(intx, CMSYoungGenPerWorker, 4*M);
    }
    young_gen_per_worker = 4*M;
    new_ratio = (intx)15;
    min_new_default = 4*M;
    tenuring_default = (intx)0;
  } else { 
    // new defaults: "new" as of 6.0
    young_gen_per_worker = CMSYoungGenPerWorker;
    new_ratio = (intx)7;
    min_new_default = 16*M;
    tenuring_default = (intx)4;
  }
  
  // Preferred young gen size for "short" pauses
  const uintx parallel_gc_threads =
  (ParallelGCThreads == 0 ? 1 : ParallelGCThreads);
  
   const size_t preferred_max_new_size_unaligned =
      ScaleForWordSize(young_gen_per_worker * parallel_gc_threads);
    const size_t preferred_max_new_size =
  align_size_up(preferred_max_new_size_unaligned, os::vm_page_size());
  </code></pre>