title: How to Find memory leaks in Java + JNI + C++ process
body: <p>I have project written in java that using JNI uses a C++ library.
  All the code was written by us, so I have all the source code.</p>
  
  <p>After few hours the machine runs out of memory although my process just iterate over files and all the memory regarding the previous file deleted.</p>
  
  <p>I'm sure that there is a memory leak, usually I use Valgrind, but it seems he can't cope with Java very well and believes that the JVM is leaking, even for "hello world" java project.</p>
  
  <p>I've tested the C++ parts (the major flows) with unit-tests and used valgrind on the unit-tests, but couldn't find any leakage. It doesn't prove anything because there are many potential flows I could've missed.</p>
  
  <p>My major question, how can I find my leak ? </p>
  
  <p>It will be extremely helpful to know who is consuming the memory, the java or the native part ? they are in the same process.</p>
  
  <p>Thanks.</p>