Setting JVM ThreadStackSize for error-free Defects/Stats Aggregration operations.

Document ID : KB000009482
Last Modified Date : 14/02/2018
Show Technical Document Details
Introduction:

For most JVMs, setting the specified thread stack size to 192 (-XX:ThreadStackSize=192) for defects and statistical aggregation is sufficient, but there are JVMs which may need more than 256.

Environment:
All Supported APM Releases supporting APM CE (CEM).
Instructions:

For the instructions below, obtain a copy of TestThreadStackSize.java from https://gist.github.com/rednaxelafx/1066792. This simple Java program sleeps 5 minutes, giving you ample time to use the jinfo JDK utility to discover the default and minimum values needed to successfully invoke a JVM.

How to determine the default thread stack size in a 32-bit JVM

  • Execute TestThreadStackSize

    • # /opt/java7/jre/bin/java TestThreadStackSize

      • Running/sleeping..... 

  • Get the PID of TestThreadStackSize

    • # /opt/java7/bin/jps -lvm

      • 21524 TestThreadStackSize 

      • 21525 sun.tools.jps.Jps -lvm -Dapplication.home=/opt/java7 -Xms8m 

    • The PID of TestThreadStackSize is 21524. 

  • Verify the default thread stack size value from the running JVM

    • # /opt/java7/bin/jinfo -flag ThreadStackSize 21524

      • -XX:ThreadStackSize=512 

    • The default thread stack size is 512.

How to determine the minimum required thread stack size in a 32-bit JVM

  • Execute TestThreadStackSize with a ThreadStackSize that is too small

    • # /opt/java7/jre/bin/java -XX:ThreadStackSize=192 TestThreadStackSize

      • Error: Could not create the Java Virtual Machine. 

      • Error: A fatal exception has occurred. Program will exit. 

    • The stack size specified is too small. Specify at least 200k. 

  • Execute TestThreadStackSize with a ThreadStackSize that is sufficient

    • # /opt/java7/jre/bin/java -Xss200k TestThreadStackSize

      • Running/Sleeping… 

    • The stack size specified is sufficient. 

  • Verify the ThreadStackSize specified

    • # /opt/java7/bin/jps -lvm

      • 21637 sun.tools.jps.Jps -lvm -Dapplication.home=/opt/java7 -Xms8m 

      • 21631 TestThreadStackSize -Xss200k 

    • # /opt/java7/bin/jinfo -flag ThreadStackSize 21631

      • -XX:ThreadStackSize=400 

    • The stack size in use is 400.

How to determine the default thread stack size in a 64-bit JVM

  • (For HP-UX JVM, add "-d64" to JVM args for 64-bit) 

  • # /opt/java7/jre/bin/java -d64 TestThreadStackSize

    • Running/sleeping..... 

  • Get the PID of TestThreadStackSize

    • # /opt/java7/bin/jps -lvm

      • 21652 sun.tools.jps.Jps -lvm -Dapplication.home=/opt/java7 -Xms

How to specify JVM ThreadStackSize for HP-UX

  • Minimum stack size for a 32-bit JVM in HP-UX is 400

    • -XX:ThreadStackSize=400 

  • When using custom JVMs under HP-UX memory limitation scenarios, we recommended using the standalone Java program TestThreadStackSize to determine the minimum stack size needed. 

  • The alternative is to use trial and error to arrive at an acceptable value for defects and stats aggregation JVM ThreadStackSize when defects and stats aggregation are configured to use a separate JVM. Trail and error may require multiple Enterprise Manager restarts until an acceptable minimum value is achieved based on error messages in the Enterprise Manager logs.