title: Understanding Java Heap dump
body: <p>I have been trying to find memory leak in my application for  a week now without any success. I tried to do a heap dump and use jhat to look at the dump and trace down the memory leak.</p>
  
  <p>Is this a best approach? Whats the best way to track down the memory leak with the heap dump.</p>
  
  <p>Appreciate your help.</p>
  
  <p><strong>VM used :</strong> java version "1.6.0_25"
  Java(TM) SE Runtime Environment (build 1.6.0_25-b06)
  Java HotSpot(TM) 64-Bit Server VM (build 20.0-b11, mixed mode)</p>
  
  <p><strong>JVM Options :</strong> -Xmx1600m -XX:+UseParallelGC -XX:MaxPermSize=256m -Xms1600m -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -verbose:gc -Xloggc:/tmp/gc.log</p>
  
  <p><strong>OOME Stack trace:</strong> Couldn't get this. The kernel killed the process with out of memory error.</p>
  
  <p><strong>GC Log :</strong> The last few lines</p>
  
  <pre><code>48587.245: [GC [PSYoungGen: 407168K-&gt;37504K(476160K)] 506729K-&gt;137065K(1568448K), 3.0673560 secs] [Times: user=3.53 sys=0.00, real=3.07 secs] 
  50318.617: [GC [PSYoungGen: 444224K-&gt;37536K(476416K)] 543785K-&gt;175177K(1568704K), 3.6635990 secs] [Times: user=3.70 sys=0.00, real=3.67 secs] 
  50453.841: [GC [PSYoungGen: 70092K-&gt;2912K(476672K)] 207734K-&gt;178513K(1568960K), 1.0164250 secs] [Times: user=1.29 sys=0.00, real=1.02 secs] 
  50454.858: [Full GC (System) [PSYoungGen: 2912K-&gt;0K(476672K)] [PSOldGen: 175601K-&gt;137776K(1092288K)] 178513K-&gt;137776K(1568960K) [PSPermGen: 60627K-&gt;60627K(74368K)], 2.0082140 secs] [Times: user=2.09 sys=0.00, real=2.01 secs] 
  52186.496: [GC [PSYoungGen: 407104K-&gt;37312K(444416K)] 544880K-&gt;175088K(1536704K), 3.3705440 secs] [Times: user=3.93 sys=0.00, real=3.37 secs] 
  53919.975: [GC [PSYoungGen: 444416K-&gt;37536K(476608K)] 582192K-&gt;213032K(1568896K), 3.4242980 secs] [Times: user=4.09 sys=0.00, real=3.42 secs] 
  54056.872: [GC [PSYoungGen: 70113K-&gt;2880K(476480K)] 245609K-&gt;216320K(1568768K), 0.9691980 secs] [Times: user=1.19 sys=0.00, real=0.97 secs] 
  54057.842: [Full GC (System) [PSYoungGen: 2880K-&gt;0K(476480K)] [PSOldGen: 213440K-&gt;99561K(1092288K)] 216320K-&gt;99561K(1568768K) [PSPermGen: 60628K-&gt;60628K(72320K)], 2.2203320 secs] [Times: user=2.23 sys=0.01, real=2.22 secs] 
  55796.688: [GC [PSYoungGen: 406976K-&gt;37504K(476160K)] 506537K-&gt;137065K(1568448K), 3.2680080 secs]
  </code></pre>
  
  <p><strong>Update:</strong> Upon checking the kernel log messages, its a oom-killer. But still why is the system killing the process, isn't it because the process eating up lot of system resources ( memory ).</p>