mixing jmh and native jni calls

Aleksey Shipilev aleksey.shipilev at oracle.com
Mon May 30 17:24:34 UTC 2016


On 05/23/2016 10:55 AM, Jens Wilke wrote:
> On Sunday 22 May 2016 09:45:42 Ymo Lists wrote:
>> I am trying to mix jmh and calling jni from a .so file in linux. When i run
>> this outside of jmh i am able to make the calls from my simplified app. I
>> understand that jmh forks a new jvm but how do i debug the forked jvm so
>> that i can see why this .so library is not getting loaded ?

As usual in these cases, I suspect LD_LIBRARY_PATH issues. If it does
load with -f 0, but not with forks, then I'd try to review the env
variables for linker (e.g. LD_LIBRARY_PATH), and try to export them.


> You can disable forking with "-f 0" and debug directly in a single JVM.

Yes. Keep in mind that -f 0 is not supposed to be used to run the actual
benchmarks. Fine for debugging the workloads, but not for performance
measurements.


> Second, check the command line arguments. maybe you need to set the library path? 
> By default JMH takes over the arguments of the parent JVM. Maybe you set different
> arguments for benchmarking? Check the first lines of output:
> 
> # JMH 1.11.3 (released 126 days ago, please consider updating!)
> # VM version: JDK 1.8.0_74, VM 25.74-b02
> # VM invoker: /opt/headissue/amd64/jdk1.8.0_74/jre/bin/java
> # VM options: -server -Xmx2G -XX:+UseG1GC -XX:+UseBiasedLocking 

Plus, you can see the final command line used to fork if you supply -v
EXTRA.

Thanks,
-Aleksey





More information about the jmh-dev mailing list