HP-UX Programmer's Guide for Java™ 2 HP Part Number: 5900-1717 Published: December 2011 Edition: 1.
© Copyright 2011 Hewlett-Packard Development Company, L.P. Legal Notices Confidential computer software. Valid license from HP required for possession, use or copying. Consistent with FAR 12.211 and 12.212, Commercial Computer Software, Computer Software Documentation, and Technical Data for Commercial Items are licensed to the U.S. Government under vendor's standard commercial license. The information contained herein is subject to change without notice.
Table of Contents 1 Introduction................................................................................................................................7 2 HotSpot Technology Tools and Commands....................................................................................8 Java™ tools pages.................................................................................................................9 Setting the class path......................................................................
Support for C++ applications built with -AA and -AP options (PA-RISC only)...........44 Dereferencing NULL pointers.......................................................................................45 Using Native Methods on HP-UX.................................................................................45 Replacing the C++ default global allocation and deallocation functions......................46 Java™ calling a native (non-Java) method...........................................................
Java Web Start technology usage .......................................................................................76 Upgrading from a previous Java Web Start version ..........................................................76 IPv6 support.......................................................................................................................76 Allocation Site Statistics and Zero Preparation -Xverbosegc.............................................76 JDK 6.0.04 flags ......................
Closing a socket when accept or read is pending (PA-RISC) - new patch information! .............................................................................................................................................91 Compatibility with previous releases ................................................................................92 Runtime Plug-In usage and configuration ........................................................................92 GC log-rotation support ..........................
1 Introduction Unless stated otherwise, the information in this Programmer's Guide applies to HP-UX, PA-RISC, and HP-UX Itanium® Processor Family systems. Java™, the programming language, creates a new paradigm of platform independence, meaning that Java™ applications, once written, can be executed on any computer system.
2 HotSpot Technology Tools and Commands Unless stated otherwise, the information in this Programmer's Guide applies to HP-UX PA-RISC, and HP-UX Itanium® Processor Family systems. HotSpot technology is the default Java Virtual Machine (JVM). If you want to run your 1.2 or 1.3 application without the HotSpot technology, you will need to use the -classic option. Versions 1.4, 5.0, and 6.0 are not supported on the Classic JVM. For more information, refer to Oracle's Java HotSpot VM Options at http:// www.
• • IPv6 support on PA-RISC and Integrity For usage information, see “IPv6 support (Internet Protocol version 6) - SDK 1.4.2.x and later” (page 29). HP debugger WDB support HP's wdb 3.0.01 and later debuggers can examine backtraces containing mixed language frames (Java and C/C++) in Java thread stacks. This simplifies debugging the VM and Java mixed-language applications. For more information, see “Using WDB to examine backtraces in Java™ thread stacks” (page 71).
• • Security tools (keytool, jarsigner, policytool, kinit, klist, ktab) Java™ IDL and RMI-IIOP Tools (tnameserv, idlj, orbd (1.4 only), servertool) Setting the class path The class path is the path that the Java™ runtime environment searches for classes and other resource files. For information on how to set the class search path (more commonly known by the shorter name, "class path") refer to Oracle's documentation at: http:// download.oracle.com/javase/1.4.2/docs/tooldocs/solaris/classpath.
Closing a socket when accept or read is pending (PA-RISC) The java command-line option -XdoCloseWithReadPending allows one thread to close() a socket when there is an outstanding read pending on that same socket from another thread. The default behavior when close() is called on a socket which has an outstanding read call from another thread is for the close() to block until the read call completes.
PHNE_27092 PHKL_25842 PHKL_25995 1.3.1.04 through 1.3.1.07 None -XdoCloseWithReadPending 11.23 None None 11.00 PHNE_26771 None 11.11 PHNE_28089 None 11.23 None None 1.3.1.14 & 1.3.1.15 PA-RISC 11.00 None None 1.3.1.15 11.11 1.3.1.08 through 1.3.1.13 PA-RISC 11.00 11.11 PA-RISC 11.23 Standard and non-standard options The HP-UX SDK for the Java™ 2 Platform tools install into either /opt/java1.2/ bin, /opt/java1.3/bin, /opt/java1.4/bin or /opt/java1.
See also Oracle's "Java™ HotSpot VM Options" at http://www.oracle.com/technetwork/ java/javase/tech/vmoptions-jsp-140102.html. • -classic (version 1.2.2 and 1.3) • -d64 (SDK version 1.4 and later) • -Dhpux.font and -Dhpux.font.dpi (version 1.2.2 and later) • -Dhpux.im.disable (version 1.2.2 and later) • -Dhpux.im.enable.awt (version 1.2.2 and later) • -Dhp.swing.use FastSwing (version 1.3.1 only) • -pa11 (version 1.2.
• • • • • • • • • • • • • • • • • • • • • • • -XX:+HeapDumpOnCtrlBreak -XX:+HeapDumpOnOutOfMemoryError Interaction of HeapDump options -XX:MainThreadStackSize= -XX:MaxDirectMemorySize= -XX:MaxNewSize= -XX:MaxPermSize -XX:PermSize -XX:NewSize= -XX:NewSizeThreadIncrease= -XX:-NoHandoff (version 1.
-Dhpux.im.enable.awt (version 1.2.2 and later) This option is a workaround to allow the java input method to work with European locale composed characters. Using this option will disable the java input method for the Asian locale. -Dhp.swing.use FastSwing (version 1.3.1 only) This option improves the performance of swing APIs for Java™ for HP-UX version 1.3.1. -pa11 (version 1.2.2 and later on PA-RISC only) NOTE: If you run HotSpot with the -pa11 flag or run on a PA 1.
foreground task until completed, regardless of how long the compilation takes. This flag is provided for users who desire more deterministic behavior of method compilation for purposes such as benchmarking. -Xbootclasspath Specify a semicolon-separated list of directories, JAR archives, and ZIP archives to search for boot class files. These will be used in place of the default boot class files in the jre/lib/rt.jar and jre/lib/i18n.jar archives normally used by the Java™ 2 software.
After the profiled applet or application terminates execution, the Java™ Virtual Machine writes the profile data to a file in the current directory. Use HPjmeter to analyze the file. -XheapInitialSizes Use the -XheapInitialSizes option to see the default value for the Java™ Heap. -Xincgc (excerpt from http://java.sun.com/products/hotspot/2.0/README.html) Enables the incremental garbage collector.
-Xms6m Default: -Xms2m -Xmx (excerpt from http://java.sun.com/products/hotspot/2.0/README.html ) Specifies the maximum size, in bytes, of the memory allocation pool. This value must a multiple of 1024 greater than 2MB. Append the letter k or K to indicate kilobytes, or m or M to indicate megabytes. Do not use this option in conjunction with the -XX:+AggressiveHeap option. Doing so will cause the options to override each other's settings for heap size.
When the -Xprep option is specified, before loading the application classes, the Java™ VM will load the specified factory class and execute the method in the class declared as: class implements Preprocessor {public static Preprocessor createPreprocessor (String arg) where Preprocessor is an interface defined as: package hp.javatools.
(excerpt below from http://java.sun.com/j2se/1.3/docs/tooldocs/solaris/java.html#options) Set the maximum native stack size, in bytes, for any thread. Each Java™ thread has two stacks: one for Java™ code and one for C code. This option sets the maximum stack size that can be used by C code in a thread. Every thread spawned during the execution of the program passed to java will have the number you specify in this option as its C stack size.
For documentation on the new garbage collectors, refer to Tuning Garbage Collection with the 1.4.2 Java™ Virtual Machine at http://java.sun.com/docs/hotspot/gc1.4.2/ index.html. -XX:+AggressiveHeap (excerpt from http://java.sun.com/docs/hotspot/ism.html) This option instructs the JVM to push memory use to the limit. It sets the overall heap to around 3850MB, the memory management policy defers collection as long as possible, and (beginning with J2SE 1.3.1.05) some GC activity is done in parallel.
To enable this functionality, use the command-line option -XX:+HeapDump or set the environment variable _JAVA_HEAPDUMP=1 before starting the Java™ application. (for example, export _JAVA_HEAPDUMP=1) This output is similar to -Xrunhprof:heap=dump. The difference is that the thread info (THREAD START) and trace info (TRACE) will not printed to the output file.
The option -XX:+HeapDumpOnCtrlBreak is available starting with SDK 1.4.2.11 and JDK 5.0.05. See the “Interaction of HeapDump Options” section. -XX:+HeapDumpOnOutOfMemoryError The HeapDumpOnOutOfMemoryError command-line option causes the JVM to dump a snapshot of the Java™ heap when an Out Of Memory error condition has been reached. The heap dump format generated by HeapDumpOnOutOfMemoryError is in hprof binary format, and is written to filename java_pid.hprof in the current working directory.
Specifies the maximum amount of memory in bytes that the Java™ NIO library can allocate for direct memory buffers. The default is 64 megabytes, which corresponds to -XX:MaxDirectMemorySize=64m. The use of direct memory buffers can minimize the copying cost when doing I/O operations. -XX:MaxNewSize= Sets the maximum size of new generation (in bytes). The arguments can now be followed by either 'k' or 'm' to specify KB or MB. For 1.2, specify KB only. Not supported in 1.3.
-XX:PrefetchScanIntervalInBytes=n Prefetch n bytes ahead for scavenge scan area. The default is 0. The ideal value may vary depending on the processor. -XX:+PrefetchScavengeFieldsAhead=n Prefetch the next n fields of objects during scavenge. The default is 0. The ideal value may vary depending on the processor. -XX:+PrefetchMarkSweep Use prefetching during full garbage collections. The default is true.
However, in Java, the range of priorities must be passed to the JVM at start-up. Therefore, we need to know the values prior to starting the application. For each of the scheduling policies: POSIX PRIORITIES: SCHED_FIFO, SCHED_RR, SCHED_RR2 The POSIX priorities range from 0 to 31 where 31 is the highest and 0 is the lowest. The number of priority levels can be changed with the kernel parameter 'rtsched_numpri' (possible values are 32-512). REALTIME PRIORITIES: SCHED_RTPRIO The range is -128 to -1.
-191 6: -189 7: -187 6: -185 8: -183 9: -181 10: -179 -XX:+ServerApp A set of XX options which may make long running server applications run faster. The XX options and their values, such as the tunable option for thread local sizes, are modified over time based on the application results we observe. For each release, the options as well as the values may be different depending upon the default values of XX options.
Enables compiler safe points. Enabling compiler safepoints guarantees a more deterministic delay to stop all running java threads before doing a safepoint operation, namely garbage collection and deoptimization. In HP SDK 1.3.1 and 1.4 releases, compiler safe points is off by default, and you may also require a HP-UX patch. Refer to the release notes for your SDK for more information. -XX:+UseOnStackReplacement (PA-RISC 1.3.1, 1.4 and later, Itanium 1.4.2 and later) Enables on stack replacement.
Features FastSwing (version 1.3x only) FastSwing is an HP feature which provides significant performance improvement for Swing Applications on a Remote X-Server. In HP's SDK 1.4.x and later, the FastSwing option is ignored because the Java™ 1.4 performance enhancements provide out-of-the-box performance for both local and remote displays, equivalent to FastSwing. To use this feature invoke java or appletviewer as follows: /opt/java1.3/bin/java -Dhp.swing.useFastSwing=true MyApp or /opt/java1.
IPv6 Support in HP-UX Java Releases HP-UX Java Platform Install HP-UX 11.11 Patches? Install HP-UX 11.23 Patches? Install HP-UX Default 11.31 Patches? Protocol Stack Use of Properties File? SDK 1.4.2.x Yes No No IPv4 No JDK 5.0–5.0.14 Yes No No IPv4 No JDK 5.0.15 and Yes later No No IPv4 Yes JDK 6.0–6.0.02 Yes No No IPv4 No JDK 6.0.03 and Yes later No No IPv6 Yes For the availability of HP-UX patches required for IPv6 support on HP-UX 11.
3 Configuration for Java™ Support Unless specified otherwise, the information in this chapter applies to both HP-UX PA-RISC and HP-UX Itanium® Processor Family systems. In addition, we recommend the following tools, both of which are freely available on this website: • HPjconfig , an HP performance tuning tool to help you with kernel configuration. HPjconfig provides kernel parameter recommendations tailored to your Java™ enterprise services and HP-UX hardware platform.
running and each running process uses many threads, you will want to increase this value. Open Files Problems occur when the value of kernel parameters are set too low for the number of files allowed to be simultaneously open in a process. Be certain that your kernel is configured so that you do not reach the limit for the number of open files for your process. Java™ opens many files in order to read in the classes required to run your application.
A callout structure is used by each thread that sleeps waiting for a time-based event. Traditionally the callout structure used by a thread is taken from a pool the size of which is controlled by ncallout. Each thread has a set of timers associated with it, e.g. for nanosleep or sleeping in select(). There are a set of BringYourOwnCallout functions that don't allocate from the pool. The maximum number of callout structures needs to be approximately the maximum number of threads.
4 Performance and Tuning Unless specified otherwise, the information in this chapter applies to both HP-UX PA-RISC and HP-UX Itanium® Processor Family systems. In your application design, remember that performance is designed into your application. Don't let it be an area ignored until just prior to release. In general, we've found these three recommendations useful for program design. 1. Maximize thread lifetimes and minimize thread creation/destruction cycles.
5 Measuring System Performance Check system activity with sar Once the system is running with a full load, check the system activity for signs of trouble. This can be done by using sar (system activity reporter). With the maximum number of users actively using the system, run this command: $ sar -o sarfile 5 60 This takes 60 samples, each one five seconds apart (for a total of five minutes), saving the binary output to sarfile.
4. 5. or file systems from that disk to a lesser used disk or to a new disk. See “Use HPjmeter to detect bottlenecks” (page 36). If %idle is frequently equal to zero, or if runq-sz (runqueue size) is frequently high (eight or more), the system is CPU bound. If system throughput is less than desired, upgrade to a faster processor or reduce computational load on the system. Check the capacity of the system tables for processes, inode cache, and file descriptors.
for HP-UX Performance tuning, Tutorials, & Training" on the Business Support Center (BSC): Performance Tuning, Tutorials, & Training or on the AllianeONE site. Use tusc for debugging The product tusc is an HP "as is" product, and is not currently supported by HP's IT Resource Center. However, it gives you another view into the system activity in addition to Java™ stack traces, GlancePlus, and HPjmeter. tusc has many options which upi can display with the command tusc -help.
6 Using Threads The HP-UX 11 and 11i operating systems support kernel threads. Each kernel thread is scheduled to run independently which can result in multiple threads running in parallel on multiple processors. The current JVM for HP-UX 11.0 and 11i uses the POSIX 1003.1x Kernel Threads API to access thread support on HP-UX 11.0 and 11i. The libpthread libraries (for PA-RISC and for Itanium) are in /usr/lib. Previously, the HP-UX 10.
Because threads from different processes, perhaps executing on behalf of different users, are competing for the same computational resources, the HP-UX scheduler adjusts the priorities of threads to prevent a high-priority, compute-bound thread from locking out lower priority threads. This adjustment of priorities is a requirement for a multi-user system. However, the Java™ language assumes a scheduling policy where thread priorities are only changed explicitly by the programmer.
7 Using Signals HP-UX Signal Interfaces HP-UX defines several signal interfaces that allow a process to specify the action taken upon receipt of a signal. The man pages sigaction(2), signal(2), sigvector(2), bsdproc(2), and sigset(2V) describe the various HP-UX signal interfaces. The man page signal(5) describes the HP-UX signals. There are two HP-UX signal types, asynchronous and synchronous.
The JVM installs signal handlers for SIGHUP, SIGINT, and SIGTERM, and if these are overridden, the shutdown hooks will not be executed. Note that for any of these signals a handler is not installed if the signal handlers' disposition is set to SIG_IGN. For instance, this could be as a result of starting the application using nohup(1). SIGABRT, SIGBUS, SIGILL, SIGIOT, SIGEMT, SIGSEGV, SIGSYS, SIGTRAP (synchronous signals) and SIGXCPU and SIGXFSZ (asynchronous signals) cause termination of the JVM.
Replaced by the -Xusealtsigs option. Instructs the JVM to use SIGUSR2 instead of the default SIGUSR1 to control the behavior of the JVM runtime. When your application requires use of a native code library that uses SIGUSR1, use this option to avoid a conflict between the two runtimes. The HotSpot VM for Itanium systems uses the following immediate value ranges on break instructions for internal use.
For more information on LD_PRELOAD_ONCE functionality and its limitations, read the man page for dld.sl after you have installed the HP-UX patch. For more information on signal chaining, go to http://download.oracle.com/javase/ 1.4.2/docs/guide/vm/signal-chaining.
8 Using Java™ 2 JNI on HP-UX NOTE: Regarding the examples contained in this chapter, do not use +D64 with Java™ 1.3 based releases on Integrity. Beginning with SDK 1.4.1 you may use +D64. Using Java™ 2 JNI on HP-UX The Java™ Native Interface, typically referred to as JNI, is a standard native method interface that allows Java™ to call up native libraries written in other languages. It also allows you to load the JVM into native applications to integrate Java™ functionality into native applications.
These are the Standard C++ Runtime version of these libraries: ./jre/lib/PA_RISC2.0/libjvm_v2.sl ./jre/lib/PA_RISC2.0W/libjvm_v2.sl ./jre/lib/PA_RISC2.0/libfontmanager_v2.sl ./jre/lib/PA_RISC2.0W/libfontmanager_v2.sl A native application must be either linked with, or must dynamically load, these versions of the Java™ libraries if your C++ application is compiled using -AA. The Standard C++ version of the JVM libraries are supported for PA_RISC2.0 and PA_RISC2.0W architectures only.
NOTE: The default stack size for 1.4 and 5.0 64-bit mode threads created by the JVM is 1MB. On PA-RISC 32 and 64-bit systems, the default stack size is 64KB. Therefore, if you are using C language main programs that attach with JNI, for threads created using the pthread library, you will want to adjust the stack size to avoid overflows. For further details on thread stack size limits, see “Main/primordial thread stack size limits” (page 57) and “Non-Main/Primordial thread stack size limits” (page 59).
program using the Java™ method:System.loadLibrary(). The implementation of this function with the JVM on HP-UX relies upon the HP-UX runtime routine shl_load. The alignment requirements for Java™ data structures allocated in the JVM are not the same as those found in the standard PA-RISC 2.0 calling conventions. The JVM requires that class instance data members 64-bits in size (longs and doubles) be allocated at the next available 4-byte boundary. The standard PA-RISC 2.
public static void main(String args[]) { String libname = args[0]; try { System.loadLibrary(libname); System.out.println("Library " + libname + " successfully loaded"); } catch (UnsatisfiedLinkError Err) { System.out.println("error: " + Err); return; } System.out.println("Calling sayHelloWorld"); sayHelloWorld(); System.out.println("All done"); } } Compile this class: $ /bin/javac -verbose TestJava2CallingNative.java Output: TestJava2CallingNative.
NOTE: You are required to supply either -Aa or -Ae as a command-line option to the C compiler. The Java™ header files that you must include require support for ANSI C prototypes. Create the shared library containing the native method implementation: PA-RISC: $ aCC -b -o libaCCImpl.sl aCCImpl.o \ -lstd -lstream -lCsup -lm (see below for Integrity) Output: libcImpl.sl Use libcImpl.
public public public String native static void initialize(); native static void sayHelloWorld(); static void main(String args[]) { libname = args[0]; try { System.loadLibrary(libname); System.out.println("Library " + libname + " successfully loaded"); } catch (UnsatisfiedLinkError err) { System.out.println("error: " + err); return; } System.out.println("initialize C++ runtime"); initialize(); System.out.println("Calling sayHelloWorld"); sayHelloWorld(); System.out.
void _main(); } JNIEXPORT void JNICALL Java_TestJava2CallingNative_initialize(JNIEnv *, jclass) { _main(); } JNIEXPORT void JNICALL Java_TestJava2CallingNative_sayHelloWorld(JNIEnv *, jclass) { cout << "aC++ says HelloWorld via iostreams" << endl; } In the above example you can see that the additional native method initialize() simply calls the routine _main().
HP aC++ Libraries with Other Languages, refer to the appropriate section within the Programmers's Guide. All HP aC++ programs require libCsup.sl (libCsup.so on Integrity). The other two libraries are required by a subset of C++ programs. In this example, we could omit libstd.sl on PA since we are not using the Standard Template Library functionality. However it is usually best to link your native method shared library against all three of these libraries.
The Invocation API is provided by the C/C++ header file jni.h. It actually provides two different interfaces. It provides a standard C interface and an object based C++ interface. Here is the sample Java™ class that we will call from C and C++ programs: // // File TestNonJavaCallingJava2.java // public class TestNonJavaCallingJava2 { public static void printInt(int arg) { System.out.println("TestNonJavaCallingJava2.
int main() { JNIEnv *env; JavaVM *jvm; JNIEnv jni; JavaVM vmi; JavaVMInitArgs vm_args; JavaVMOption options[4]; jint res; printf("beginning execution...\n"); /* * User-defined classes options[0].optionString = (char *) \ "-Djava.class.path=."; vm_args.version = JNI_VERSION_1_2; vm_args.options = options; vm_args.nOptions = 1; vm_args.ignoreUnrecognized = JNI_FALSE; /* * The CLASSPATH environment variable does not * set the classpath for JNI applications that * have a native main program.
$ cc -O -c -Ae +u4 -mt -I/include \ -I/include/hp-ux c_main.c Output: c_main.o Link the main executable. cc -z -o c_main c_main.o \ -L/jre/lib/PA_RISC2.0/hotspot \ -ljvm -lpthread -llwp On Integrity, the command to the main program would look like this: $ cc -z -o cmain cmain.o \ -L/jre/lib/IA64/hotspot \ -ljvm -lpthread Output: c_main NOTE: If you are using SDK 1.2 or 1.
//create a new Java™ Virtual Machine //and locate the class TestNonJavaCallingJava2 //and invoke the static method printInt #include #include #include int main() { JNIEnv *env; JavaVM *jvm; JNIEnv jni; JavaVM vmi; JavaVMInitArgs vm_args; JavaVMOption options[4]; jint res; cout << "beginning execution..." << endl; options[0].optionString = (char *) \ "-Djava.class.path=."; /* user classes */ vm_args.version = JNI_VERSION_1_2; vm_args.options = options; vm_args.
Output: aCC_main.o Create the main program and link: $ aCC -z -o aCC_main aCC_main.o \ -L/jre/lib/PA_RISC2.0/hotspot \ -ljvm -lpthread -llwp NOTE: If you are using SDK 1.2 or 1.3 and your C main is linked EXEC_MAGIC so as to be able to address more than 1GB of private data, you must either use Hotspot JVM or the Classic JVM with the "-nojit" option. The JIT compiler in Classic 1.2 and 1.3 is not compatible with EXEC_MAGIC.
situation in the native code itself, even if no Java™ code was ever run on the primordial thread. Another point to consider is the effect of maxssiz on the overall amount of writeable data space available to the application. The kernel automatically protects some memory above maxssiz away from the primordial stack base to enforce the maxssiz limit.
1. 2. 3. Use the option -XX:MainThreadStackSize= to increase the primordial thread stack size, However be aware that -XX options are non-standard options, and are liable to change from release to release. Use the -Xss option to set the thread stack size. This workaround may be less desirable because -Xss sets the stack size for all threads, not just the primordial thread.
NOTE: The examples below work as is for Java™ 1.3.1.x and 1.4.2.x on PA-RISC. If you wish to take advantage of the new JNI features in 1.4.2, in the example below you should change the line vm_args.version = JNI_VERSION_1_2; to vm_args.version = JNI_VERSION_1_4; Below is an example of how to dynamically load the shared library libjvm.sl, (libjvm.so for Integrity), create a new JVM, locate the class TestNonJavaCallingJava2, and invoke the static method printInt. #include #include
} else fprintf (stdout, "after CreateJavaVM \n"); jni = *env; vmi = *jvm; // find the class fprintf (stdout, "before FindClass\n"); jclass cls=env->FindClass("TestNonJavaCallingJava2"); if (cls == 0) { fprintf (stderr, "Could not locate class TestNonJavaCallingJava2 in clas\ spath %s\n", options[0].
export SHLIB_PATH=$JAVA_HOME/jre/lib/PA_RISC2.0/hotspot:$JAVA_HOME/jre/lib/\ PA_RISC2.0 export CLASSPATH=. (Note: we are using the same TestNonJavaCallingJava2.class from prior examp\ les) # Run program # Use JAVA_PRELOAD_ONCE if want to dynamically load library with TLS (e.g. \ HotSpot). For Integrity, substitute IA64 or IA64N for PA_RIS2.0, and substitute libjvm.so for libjvm\ .sl JAVA_PRELOAD_ONCE=$JAVA_HOME/jre/lib/PA_RISC2.0/hotspot/libjvm.sl ./loadjav\ a # Output: #TestNonJavaCallingJava.
9 Expanding Memory Determine your requirements It is important to understand the real requirements of your application. We recommend that you perform sizing tests before deployment with a realistic load, while monitoring with -Xverbosegc and a tool like GlancePlus. Learn more about GlancePlus and the -Xverbosegc option. Our Java™ Performance Tuning website has much valuable information on profiling and performance tools. In addition, HP-UX patches may be needed for expanding memory size.
The PA1.1 binary is not EXEC_MAGIC because the jit in Classic is not compatible with EXEC_MAGIC. The PA2.0 launcher binary is EXEC_MAGIC. With EXEC_MAGIC, we have all the space from around 0x00008000 until 0x80000000 as writeable data area. Now the C heap will start way down there. This allows us to allocate a Java™ heap larger than 1GB. However, you should be aware of certain considerations which might be application dependent.
The JVM doesn't necessarily use all the space that it's reserved for the Java™ heap. On initialization it commits a portion of this memory, the size of which is controlled by the -Xms option. The size of this committed area (as shown by the capacity value in the -Xverbosegc output) can vary between this minimum value and the maximum allowable size (controlled by the -Xmx option), as the amount of retained objects in the heap increases and decreases. Starting with SDK 1.4.1.
Tells the JVM to reserve the swap space for all large memory regions used by the JVM (Java™ heap). This effectively removes the MAP_NORESERVE flag from the mmap call used to map the Java™ heaps and ensures that swap is reserved for the full memory mapped region when it is first created. When using this option the JVM no longer needs to touch the memory pages within the committed area to reserve the swap and as a result , no physical memory is allocated until the page is actually used by the application.
recommend that you perform sizing tests before deployment with a realistic load, while monitoring with the -Xverbosegc option and a tool like GlancePlus. • For more on the -Xverbosegc option, see Chapter 2 (page 8). • For more information on GlancePlus, see http://www.openview.hp.com/products/ gplus/. • For more information on performance tuning Java™ on HP-UX, see the Performance Tuning website. Expanding heap size in native applications on PA-RISC HP-UX 11.
in JVM like permanent generation, code cache and interpreter, and other reserved address range and alignment. When Java™ is invoked from the command line on HP-UX PA-RISC, Hotspot automatically chooses an appropriate executable. This is how Hotspot chooses the executable for SDK 1.4.2.09 and JDK 5.0.01 and older releases: • For heaps less than 1500MB, the executable is 'java'. • For heaps greater than or equal to 1500MB, and less than 2400MB the executable is 'java_q3p'. • For heaps of 2400MB to 3.
Expanding heap size in HP-UX Integrity NOTE: The numbers provided in this section are approximate and might change from release to release. Hotspot 1.4.2.X/5.0.X/6.0.X running in 32-bit mode supports heaps larger than 3GB on HP-UX 11.23 and later. In theory, an mpas 32-bit process on HP-UX 11.23 and later can have 4GB address space.
an MPAS executable can have close to 4GB private address space. HP JVM for IPF HP-UX with large data space support is an MPAS executable and named java_q4p.
10 Diagnosing Memory Leaks Using WDB to examine backtraces in Java™ thread stacks You can now use HP's debugger WDB 3.0.01 or later (the GNU Debugger GDB) to examine backtraces containing mixed language frames (Java™ and C/C++) in Java™ thread stacks. This will simplify debugging the VM and Java™ mixed-language applications. Set the environment variable GDB_JAVA_UNWINDLIB to the path name of the Java™ Unwind Shared Library libjunwind, which is in the JDK.
Currently, the first two cases require a command line like the following: java -Xdebug -Xnoagent -Djava.compiler=NONE-Xrunjdwp:transport=dt_socket,server=y,suspend=y-classpath class-path class-name The -Xdebug option enables debugging. The -Xnoagent option disables the default sun.tools.debug debug Agent. The -Djava.compiler=NONE option disables the JIT compiler.
We recommend you make a short and a long run. You can compare the two runs in HPjmeter, and view the residual objects. Generally the lingering objects will percolate to the top of the residual objects histogram, especially if the difference in run duration is large enough or the leak rate is very high. Then you can look for objects of this type in the Reference Graph. Following the graph from a candidate leaked object back towards the root, you can see how that object is referenced by the application.
A JDK/JRE 6.0.n and 7.0.n Usage Notes This appendix provides usage notes for the HP-UX Java™ JDK/JRE 6.0.n and 7.0n. version streams. Note, however, that any usage notes pertaining to PA-RISC systems, JPI (Java Plug-In), or Java Web Start, are JDK/JRE 6.0.n only, and do not apply to JDK/JRE 7.0.n. Using Java 2 JNI on HP-UX For C and C++ applications, it is important to link with the -mt (multithread) option if the application calls a Java VM. Both executables and shared libraries must be linked with -mt.
incompatibilities with other native code or profiling tools that use SIGUSR2 or SIGPROF. You can turn off both handlers by using the -XX:+ReduceSignalUsage option. If you do this, be aware that this option also turns off the SIGQUIT handler, and, therefore, you will not be able to get a Java stack trace. You can turn off just the SIGUSR2 handler by using the -Xeprof:off option, thereby retaining the ability to get a Java stack trace using SIGQUIT.
Java Web Start technology usage Java™ Web Start is an application-deployment technology, which gives you the power to launch full-featured applications with a single click from a web browser. It is located in the jre directory. Some of Java Web Start's features include: • Runs independently of any browser, so you can shut down your browser or go to another web page and continue using your application. • Applications deployed with Java Web Start do not require a browser interface to operate.
kill -21 6754 kill -s sigprof 6754 Issuing a second SIGPROF signal to the running Java program prompts the JVM to stop emitting the -Xverbosegc information. Similarly, issuing yet another SIGPROF signal to the running process prompts the JVM to start issuing -Xverbosegc information one more time.
Allocation Site Statistics Data Location Action JVM Flags Specified No special action taken -XX:+PrintAllocStatistics Standard out 'kill -21 ' -XX:+PrintAllocStatistics JVM will create a file for you, file name format is: java_.vgc 'kill -21 ' -XX:+PrintAllocStatistics Standard out -Xverbosegc 'kill -21 ' -XX:+PrintAllocStatistics Same location as -Xverbosegc -Xverbosegc:file=mydata.vgc data file (mydata.
In 64-bit mode, users can specify larger values for this cache. When specifying large cache values, users should also consider the overhead of cache lookup. Lookup time increases as the size of the cache increases resulting in negative effect on performance. This caching is disabled by default. Additionally, the -XX:HeapDumpPath= option can be used to specify the heap dump file name or a directory where the heapdump should be created. Starting with the JDK 6.0.
processor in the system has a local memory that provides low access latency and high bandwidth, and remote memory that is considerably slower to access. In the Java HotSpot Virtual Machine, the NUMA-aware allocator has been implemented to take advantage of such systems and provide automatic memory placement optimizations for Java applications. The allocator controls the eden space of the young generation of the heap, where most of the new objects are created.
Concurrent Mark-Sweep GC (widely referred to as CMS). G1 runs largely concurrently with your application, but with short pauses that are more predictable than those required by CMS. Unlike CMS, G1 also performs heap compaction to reduce fragmentation. You can enable this experimental version of G1 with the –XX:+UseG1GC option. More information can be found at: http://www.oracle.com/technetwork/java/ javase/tech/g1-intro-jsp-135488.html.
B JDK/JRE 5.0.n Usage Notes This appendix provides usage notes for the HP-UX Java™ JDK/JRE 5.0.n version stream. Using Java 2 JNI on HP-UX For C and C++ applications, it is important to link with the -mt (multithread) option if the application calls a Java VM. Both executables and shared libraries must be linked with -mt. Use of -mt must be consistent during both compilation and linking. For more information, see “Native (non-Java) calling Java™ methods” (page 52).
If your application requires that system time changes are immediately reflected, you can use the -XX:+UseGetTimeOfDay option to tell the JVM to use the gettimeofday call instead of the new, lightweight mechanism. However you may notice a drop in performance. Profiling Currently a SIGUSR2 handler to support -Xeprof profiling and a SIGPROF handler to support future profiling capability are automatically installed.
Unlimited strength jurisdiction policy files may be downloaded from the JavaSoft Web site. Allocation Site Statistics and Zero Preparation -Xverbosegc NOTE: To properly view Zero Preparation -Xverbosegc and Allocation Statistics information, you must use HPjmeter 3.1 or later. Starting with the JDK 5.0.14 release, you can prompt the JVM to emit HP -Xverbosegc information for Java applications started without -Xverbosegc.
and allocation site statistics is directed to a file created for you by the JVM. The name of the file created by the JVM has the following format: java_.vgc. Where is the Java process id. The following table lists all possible permutations and corresponding locations of emitted data for both allocation site statistics and zero preparation -Xverbosegc.
For usage information, such as how to change the default IP version for JDK 5.0, see “IPv6 support (Internet Protocol version 6) - SDK 1.4.2.x and later” (page 29). Additional information is also available at Oracle Networking IPv6 User Guide for J2SDK/JRE 1.4. GC log-rotation support in 5.0 Prior to JDK5.0.17, when using GC logging options (for example, -Xverbosegc or -Xloggc), GC data is written to a single file of unlimited size. Starting with JDK 5.0.
the RTLD_GLOBAL flag in the dlopen() call used for dynamically loading libraries containing Java native methods. -XX:+DllLoadGlobal is the default for 5.0.19 and later, and is equivalent to the behavior in 5.0.17 and earlier releases. -XX:-DllLoadGlobal is the default only for 5.0.18 (and for 6.0 releases). This option does does not affect 32-bit PA-RISC because the 32-bit PA-RISC version of dlopen() always behaves as if the RTLD_GLOBAL flag was given.
cache to be cleared and all of the previously installed Java Web Start applications will need to be downloaded again. This version will overwrite previous installations and automatically update browsers to use this new release. In order to reactivate a previous version after installing this new release, you must reinstall the old version. The configuration files and program files folder used by Java Web Start have not changed, so all your settings will remain intact after the upgrade.
C SDK/RTE 1.4.2.n Usage Notes This appendix provides usage notes for the HP-UX Java™ SDK/RTE 1.4.2.n version stream. Removing support for unwanted architectures in the JRE Under the RTE license agreement, partners who redistribute the RTE may remove support for unwanted architectures. Functional components may NOT be removed under any circumstances. Beginning with the 1.4.2.
patches). For HP-UX 11.11 (11i v1), the feature is included. For more information on LD_PRELOAD functionality and limitations, read the man page for dld.sl after you have installed the patch. Signal Chaining functionality With signal chaining functionality, applications can now use signals that the JVM uses and they will not interfere with the JVM's functionality. For signal chaining, the application must load the library libjsig.sl (PA) or libjsig.so (Itanium) before libc.2.
For more details on why this occurs and for examples of using key command line options, see “Allocating physical memory and swap in the Java™ heap” (page 64). Asian TrueType fonts and Asian locales Asian locales are supported by HP's JDK 1.4 with TrueType fonts. For more details, see HP-UX Fonts and the Java™ Runtime Environment at: http://www.hp.com/go/hpux-java-docs Date/Time methods defaults The HotSpot JVM uses the gettimeofday() system call to obtain date and time information.
Compatibility with previous releases Oracle maintains upwards compatibility. Therefore, an application written for a 1.3 JVM will run on a 1.4 JVM. Downward compatibility is generally not supported because new APIs are introduced that do not run on earlier JVMs. For a detailed description of the incompatibilities between 1.3 and 1.4, refer to http:// java.sun.com/javase/compatibility_j2se1.4.html .
Information on Oracle HTML converter and specification is available at http:// www.oracle.com/technetwork/java/index-jsp-142903.html. You may want to use it to modify your HTML pages to specify use of the Runtime Plug-in for HP-UX, Java Edition, version 1.4.x instead of the default browser version of the HP-UX Runtime Environment for Java. GC log-rotation support Prior to SDK 1.4.2.
D Additional Resources You can find additional HP and Oracle Java documentation at the following websites: • HP-UX Java documentation at http://www.hp.com/go/hpux-java-docs • HP-UX Java Downloads • Oracle Technology Network for Java Developers • Java SE at a Glance • Java SE Technologies • Java Platform, Standard Edition 6 Overview • Summary of new features and enhancements in 6.0 • Java SE 6 Documentation • Java™ Platform, Standard Edition 6 API Specification • Java 2 JDK Tools and Utilities (6.0) • JDK 5.
Index Symbols --Xmn, 17 --Xms, 17, 65 --Xmx, 18, 65 -AA, 44 -AP, 44 -classic, 14 -classpath, 75, 87, 92 -cp, 75, 87, 92 -d64, 14 -DdfCacheSize=n, 78 -Dhp.swing.use FastSwing, 15 -Dhpux.font, 14 -Dhpux.font.dpi, 14 -Dhpux.im.disable, 14 -Dhpux.im.enable.awt, 15 -Djava.net.
B backtraces examining, 71 C C language, 39 C native application example: calling Java method, 53 C native method example: calling from Java, 47 C++ applications built with -AA and -AP options, 44 libfontmanager, 44 libjvm, 44 C++ native application example: calling Java method, 55 C++ native method example: calling from Java, 49 class path, 10 CLASSPATH environment variable, 44, 75, 87, 92 compatibility, 75, 83, 92 configuration support, 31 open files, 32 threads, 31 timeouts, 32 user limits, 33 cryptogra
dynamically loading the Hotspot JVM, 59 main/primordial thread stack size limits, 57 native program calling Java method, 52 non-main/primordial thread stack size limits, 59 overriding new and delete in C++, 46 using native methods on HP-UX, 45 using on HP-UX, 44 JNI_AttachCurrentThread, 57 JNI_CreateJavaVM, 45, 57 JPDA, 8 jstack, 81 JVMTI, 8 L launching application VM, 71 LD_PRELOAD_ONCE, 42 leak memory, 71, 72 libfontmanager, 44 libjsig, 42 libjvm, 44, 74, 82, 90 libjvm.sl, 52 libjvm.so, 52 libpthread.
interfaces, 40 LD_PRELOAD_ONCE, 42 libjsig.