Search code examples
javaxmlxerces

StackOverflowError on Solaris but not on Linux/Windows


I have a Java application that parses a large xml schema (.xsd) using Xerces that runs fine on Linux and Windows but gives a StackOverflowError on Solaris, with exactly the same inputs and configuration. I know that Xerces uses recursion to validate xml schemas but since it didn't give any problems on Windows and Linux I was pretty confident that it run everywhere.

Why does this happen? Is there a workaround?


Solution

  • According to this page, the default stack size depends on the OS.

    Sparc: 512

    Solaris x86: 320 (was 256 prior in 5.0 and earlier) (update: According to this page, the size of the main thread stack comes from the ulimit. The main thread stack is artificially reduced by the vm to the -Xss value)

    Sparc 64 bit: 1024

    Linux amd64: 1024 (was 0 in 5.0 and earlier) (update: The default size comes from ulimit, but I can be reduced with -Xss)

    Windows: 256 (also here)

    You can change the default setting with the -Xss flag. For example:

    java ... -Xss1024k ... <classname>
    

    would set the default stack size to 1Mb.