Visit Azul.com Support

Native Launch

Need help?
Schedule a consultation with an Azul performance expert.
Contact Us

A native launch application is any application that is written in a language other than Java and calls JNI_CreateJavaVM to create the Azul Zing Builds of OpenJDK (Zing) and makes calls to Java code. This is usually written in C/C++ and contains the “main” function to start execution.

Invoking Native Launch with Zing

If Native (C/C++) applications invoke Zing, consider these issues before you execute your code.

  • Native launch application — Identify how the native app creates the VM to find possible collisions with areas used by or allocated by Zing.

  • Consider known limitations when running native apps on Zing. Identify the issues by the failure messages.

  • Invoking Zing — check for differences between a stock build and a Zing build.

  • Native apps should also know how to run Zing-specific features such as the Tick Profiler mechanism and C-Heap Leak detection.

Consult the cases listed below to determine your best course of action:

Bad address errors for CodeCache and OopTable: temporary az_mreserve failed.
 
Failure message: Error: temporary az_mreserve(CodeCache) failed: Bad address at (0xNNNNNN for 0xNNNNNN bytes) Failure message: Error: temporary az_mreserve(OopTable) failed: Bad address at (0xNNNNNN for 0xNNNNNN bytes)

Virtual address space collisions when native launch applications allocate memory where Zing allocates certain internal structures like the CodeCache and the OopTable.

Solution:

If any of the reported messages are encountered, native launch applications should try to LD_PRELOAD libc_hooks3.so or call JNI_CreateJavaVM early on in the main function before calling routines that may allocate memory.

libc_hooks3.so is available in $JAVA_ HOME/etc/zing/lib/.

Problems using signal handlers

Native launch application uses signal handlers for signals used by Zing.

Solution:

Please use libjsig.so to chain user signal handlers correctly behind Zing’s signal handlers. libjsig.so is available under $JAVA_HOME/jre/lib/amd64/server/libjsig.so.

Dependency on libc_hooks3.so or LD_PRELOAD libc_hooks3.so

Native launch applications will have to link against libc_hooks3.so or LD_PRELOAD libc_hooks3.so in the following scenarios:

  • When using -XX:+UseTickProfiler

  • When using -XX:+CHeapLeakDetection

  • When there is a collision in the low 2 GB of virtual address space

Solution:

Applications can either modify the code to load libjvm.so early or load libc_hooks3.so, which will reserve upfront the space needed for the VM in the low 2 GB of virtual address space.

libc_hooks3.so is available in $JAVA_HOME/etc/zing/lib/.

Threads can come under the tick profiler scanner and allocations can come under the leak detection scanner only after VM initialization.

Note
Starting with Zing 18.12.0.0 release, native applications linked with libc_hooks2 will fail. To avoid the failure, rebuild your native application with libc_hooks3 which is in <JAVA_HOME>/etc/zing/lib.