How to measure stack memory in Java?

java, jvm, stack-overflow

Solution

Give Java VisualVM a try. It's from Oracle, and included with the JDK. You can find it here:

${JDK}/bin/jvisualvm.exe

Almost anything you want to know about your Java application's performance can be observed through this.

Here's a quick tutorial if you need it, although it doesn't actually need much of an explanation.

Problem

There is a single core class that is used in transaction engine. I did a test with high number of concurrent transaction which resulted in a deadly stack-overflow exception. I would like to know if there is any way to measure how much stack memory is available in order to avoid the exception. I am looking into a dynamic way of doing it as setting a hard limit on the number of concurrent transactions is not ideal.

Original source