|
From: rich.fromm <nos...@ya...> - 2008-02-20 05:21:26
|
I have a Java application that runs code in a C library via JNI. I have reason to believe that the C code is leaking memory, and I would like to use valgrind to instrument it. >From reading the FAQ, and various threads on this e-mail list, it seems like this should be possible in theory. I am prefacing my java execution call with the following arguments: valgrind --tool=memcheck --leak-check=full --smc-check=all -v No problems are being reported, but I suspect that the problem is that the code that I care about isn't actually being instrumented at all. As other *.so files are read, there are messages output like: Reading syms from foo.so Reading debug info from bar.so But I never see any such message for the *.so containing the JNI code. It is loaded via a call to System.loadLibrary() in the static section of a Java class, in case that matters. I tried adding "--trace-children=yes" to my execution line, and now there are all sorts of errors reported in /usr/lib/j2sdk1.5-sun/jre/lib/i386/client/libjvm.so, but I suspect that these are false positives, and just indicative of things that Sun's JVM does that valgrind can't understand. I tried adding "--trace-syscalls=yes" to my execution line, and I don't see any evidence of the *.so file containing the JNI code being opened. I'm using the Sun JVM via the sun-j2sdk1.5 Debian package, version 1.5.0+update06, on debian 3.1 (sarge). The C code including the *.so file was compiled with gcc 3.3.5. Thanks for any help that anyone might be able to provide. - Rich Fromm -- View this message in context: http://www.nabble.com/memcheck-of-JNI-library-loaded-via-System.loadLibrary%28%29-tp15582655p15582655.html Sent from the Valgrind - Users mailing list archive at Nabble.com. |
|
From: rich.fromm <nos...@ya...> - 2008-02-20 23:38:46
|
rich.fromm wrote:
>
> No problems are being reported, but I suspect that the problem is that the
> code that I care about isn't actually being instrumented at all.
>
> As other *.so files are read, there are messages output like:
>
> Reading syms from foo.so
> Reading debug info from bar.so
>
> But I never see any such message for the *.so containing the JNI code.
>
> ...
>
> I tried adding "--trace-syscalls=yes" to my execution line, and I don't
> see
> any evidence of the *.so file containing the JNI code being opened.
>
I have found out how to at least allegedly get valgrind to profile my *.so,
by
setting the LD_PRELOAD environment variable to contain the name of the file.
Then I see the message:
Reading syms from <filename>
and if I run with --trace-syscalls=yes I see a sys_open() call on the file.
valgrind still isn't reporting any leaks in my code, so I still need to
explore further, but I thought I'd share this datapoint in case it benefits
anyone else.
LD_PRELOAD is documented in the LD.SO(8) man page:
LD_PRELOAD
A whitespace-separated list of additional, user-specified, ELF
shared libraries to be loaded before all others. This can be
used to selectively override functions in other shared
libraries. For setuid/setgid ELF binaries, only libraries in
the standard search directories that are also setgid will be
loaded.
- Rich
--
View this message in context: http://www.nabble.com/memcheck-of-JNI-library-loaded-via-System.loadLibrary%28%29-tp15582655p15601589.html
Sent from the Valgrind - Users mailing list archive at Nabble.com.
|