Problem: ArcGIS Engine Java application throws "EXCEPTION_STACK_OVERFLOW"


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:


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.

Solution or Workaround

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.

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:
  • Use the JVM option, –Xss<size>m, to increase the thread's stack size to a sufficiently large value (~2M)

    For example, to run a Java Sample, from the /bin folder run the following:
    java -jar -Xss4m -client samplename.jar
    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.
    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.
  • Use Microsoft's 'EditBin' utility

    EditBin is a utility that changes the default stack size of all the threads created from within an application by directly modifying the executable itself. (java.exe/javaw.exe). EditBin is available as part of Microsoft Visual Studio.
  • Use Esri's EditBin utility

    If Microsoft’s EditBin utility cannot be accessed, use Esri's utility:
    1. Download the .zip file, and extract it to a folder, for example, 'temp'.
    2. Open a command prompt and navigate to the temp folder. To increase the java.exe's stack space, issue the following command:
      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