Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 356
lawsonj2019 Avatar asked Oct 08 '08 20:10

lawsonj2019


2 Answers

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

like image 69
Declan Shanaghy Avatar answered Oct 23 '22 10:10

Declan Shanaghy


Have you tried using Process Viewer to dig deeper.

If you have the source to the DLL you could rebuild with debug libraries and possibly a mem allocation tracker - and debug using visual C++ debugger (you'll need to tell it to use the java application).

If you haven't got the source - then the options are limited.

like image 40
Richard Harrison Avatar answered Oct 23 '22 11:10

Richard Harrison