title: JVM heap sizing in VMware guests
body: <p>This question is probably better phrased: how does running a Java server on a hypervisor such as VMware ESX affect the Java heap?</p>
  
  <ul>
  <li>Access to JVM heap is random from the OS/hypervisor perspective</li>
  <li>It is difficult to for guest OS or hypervisor to optimize memory that is randomly accessed</li>
  <li>Given this, can the hypervisor detect unused pages in JVM heap?</li>
  </ul>
  
  <p>The conventional wisdom for Java server applications is that performance is best if you allocate all the heap at JVM startup, rather than allowing the heap to be dynamically resized as the need arises. In other words, if you set the heap size to 1GB, your Java process will grab 1GB of contiguous virtual address space (+ whatever is needed for the binaries), memory which is no longer available to other applications.</p>
  
  <p>Is VMware smart enough to detect that some of this heap is in fact unused? How does this affect GC performance? Would it be better to let the heap be dynamically resized in VMware? What GC strategies work best with VMware guests?</p>
  
  <p>Also, would anyone point me towards guidelines for tuning JVM heaps in virtualized environments?</p>