I\'m trying to profile native memory allocated by C-written methods and plugged to JVM
through JNI
. I installed
$ valgrind --version
v
Valgrind (and Valgrind-based tools) does not work well with self-modifying code. However, HotSpot JVM heavily relies on dynamic code generation, including overwriting and patching the previously generated instructions. This holds even when JIT compiler is disabled, because HotSpot also uses dynamic code generation for interpreter and runtime stubs.
For native memory allocation profiling you may also use jemalloc or async-profiler. The latter has the advatange of integration with Java runtime, i.e. it can show mixed stack traces with both native and Java frames. Furthermore, both tools have rather small performance overhead unlike Valgrind which virtualizes the running program.
For more information see this and this answers.