title: Why is my Java heap dump size much smaller than used memory?
body: <h1>Problem</h1>
  
  <p>We are trying to find the culprit of a big memory leak in our web application. We have pretty limited experience with finding a memory leak, but we found out how to make a java heap dump using <code>jmap</code> and analyze it in Eclipse MAT. </p>
  
  <p>However, with our application using 56/60GB memory, the heap dump is only 16GB in size and is even less in Eclipse MAT. </p>
  
  <h2>Context</h2>
  
  <p>Our server uses Wildfly 8.2.0 on Ubuntu 14.04 for our java application, whose process uses 95% of the available memory. When making the dump, our buffers/cache used space was at 56GB.</p>
  
  <p>We used the following command to create the dump: <code>sudo -u {application user} jmap -dump:file=/mnt/heapdump/dump_prd.bin {pid}</code></p>
  
  <p>The heap dump file size is 16,4GB and when analyzing it with Eclipse MAT, it says there are around 1GB live objects and ~14,8GB unreachable/shallow heap. </p>
  
  <p><strong>EDIT:</strong> Here is some more info about the problem we see happening. We monitor our memory usage, and we see it grow and grow, until there is ~300mb free memory left. Then it stays around that amount of memory, until the process crashes, unfortunately without error in the application log. </p>
  
  <p>This makes us assume it is a hard OOM error because this only happens when the memory is near-depleted. We use the settings <code>-Xms25000m -Xmx40000m</code> for our JVM. </p>
  
  <h2>Question</h2>
  
  <p>Basically, we are wondering why the majority of our memory isn't captured in this dump. The top retained size classes don't look too suspicious, so we are wondering if there is something heap dump-related what we are doing wrong. </p>