Is This Content Helpful?
We're glad to know this article was helpful.
This problem is observed when an ArcGIS Engine Java application is run from the command line. The following is an example of the console output:
An unrecoverable stack overflow has occurred. # # An unexpected error has been detected by HotSpot Virtual Machine: # # EXCEPTION_STACK_OVERFLOW (0xc00000fd) at pc=0x7227f575, pid=5488, tid=4648 # # Java VM: Java HotSpot(TM) Client VM (1.8.0_65-b17 mixed mode, sharing) # Problematic frame: # .... # # An error report file with more information is saved as hs_err_pidXXXX.log # # If you would like to submit a bug report to Oracle, please visit: # http://bugreport.java.com/bugreport/crash.jsp #
The executing Java thread runs out of stack space during execution, which causes the Java Virtual Memory (JVM) to terminate and the application to crash. This is due to the default stack size, which is 256KB per thread.
The JVM supports a command line option, -Xss<size>[k|K|m|M|g|G], that allows changing the default stack size of a thread.
On the Windows operating system, this command line option affects only the stack sizes of (worker) threads created from within the main thread. (On Windows, the stack size for the main thread is configured into the executable itself java.exe/javaw.exe.)
On Linux, the -Xss<size>m option also affects the main thread.
Note: For a detailed discussion on the stack sizes of threads in Java on Windows and UNIX platforms, please refer to the following post: Oracle Technology Network Bug Detail.There are three possible solutions to this problem:
java -jar -Xss4m -client samplename.jar
Note: If on Linux, don't forget to source the init_java.sh or init_java.csh from the install location (%AGSDEVKITJAVA%) depending on the user shell.With Java 5, this JVM option only increases the stack size of secondary threads, not the main thread. Hence, the offending ArcObjects operation must be performed on a secondary thread. With Java 6 and up, even the main thread's stack size is modified by this option. Hence, the ArcObjects operation can be performed on the main thread itself.
Note: Remember, ArcObjects always runs in a single-threaded environment. So, if the JVM option is selected and the application is initialized to run in Engine-mode (EngineInitialize.initializeEngine()), then all the ArcObject's work (including, but not limited to, the interop initialization and the offending operation) must be performed strictly on the secondary thread.
EditBin.exe <path_to_java_exe> <stack_size_in_bytes>For example, the following command increases the stack size to 2Mb:
EditBin.exe "c:\jdk1.5.0_06\jre\bin\java.exe" 2097152