I'm working with a vendor who has provided me a Java application which I'm trying to get up and running on a Linux OS (CentOS 7). The vendor builds, runs and tests the application on Windows.
The application starts up just fine on my Linux system. But from time to time, I'm seeing a stack overflow come up. The vendor swears that this never happens on Windows.
Note that I am in no way a Java expert, so apologize if this is an incoherent rambling, but after a little research, I decided to try increasing the JVM stack size to 8MB from the default size using a -Xss8m
parameter. With that, the application starts up just fine, but sure enough I encounter another stack overflow.
The vendor's comment on this never happening on Windows makes me wonder (while also making a lot of assumptions) if Linux is somehow implementing a limit that would now allow the JVM to create a 8MB stack.
However, after running ulimit -s
as the user executing the process, I find the default Linux stack limit is 8MB! As an experiment, I've set the stack limit value to unlimited
. Waiting to see what happens.
This leaves me with a few things to ponder, which maybe someone on here can help me understand.
- Is there something else I could possibly be missing in the environment that can cause the Java application to use up all its stack?
- If not, I'll need to go back to the vendor and get a better understanding of their code, looking for deep recursion where the stack overflow seems to happen most.
Some additional details about my environment:
- Linux 3.10.0-1160.15.2.el7.x86_64 (CentOS 7)
- OpenJDK 11
- Other Java options related to memory utilization being passed while experimenting:
Xms1g
Xmx1g
Xss8m
XX:VMThreadStackSize=8192
XX:PermSize=128m
XX:MetaspaceSize=1g
XX:MaxMetaspaceSize=1g
XX:CompressedClassSpaceSize=256m
XX:ReservedCodeCacheSize=64m
XX:+UseG1GC
XX:+UseStringDeduplication
XX:MaxGCPauseMillis=200
XX:+UseCompressedOops