Java – Monitoring memory usage for a C DLL called with Java via JNI

cdlljavajava-native-interfacememory

How can I monitor the memory being used by a native C DLL that is being called from Java via JNI? Using standard Java monitoring tools and options I can see the Java memory space, but I cannot view any memory used by the C DLL. Java is using ~70MB, but the task in the Task Manager shows 200Mb+, and I'd like to see what's in that 130MB extra if possible.

Best Answer

You can monitor the native heap with counters in the performance montitor. (perfmon32) however it wont break it down for you on a per DLL basis, even jvm.dll will be included here.

Most profiling tools out there can attach to a process and capture and track memory allocations and deallocations. This allows them to speculate where leaks are. One pretty good one i found when recently trying to track down memory leaks in native code which was called from Java is Memory Validator