Back to Zing Documentation Home

Native Launch with ZVM

A native launch application is any application that is written in a language other than Java and calls JNI_CreateJavaVM to create the VM 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 jZVM, 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 the ZVM.
  • Consider known limitations when running native apps on Zing. Identify the issues by the failure messages.
  • Invoking the ZVM -- 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:

Error Description Solution

Bad address errors for CodeCache and OopTable.

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 ZVM allocates certain internal structures like the CodeCache and the OopTable.

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 the ZVM.

Please use libjsig.so to chain user signal handlers correctly behind the ZVM’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

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 the 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.


© Azul Systems, Inc. 2020 All rights reserved.

Privacy Policy | Legal | Terms of Use