Ali
Ali

Reputation: 949

How to measure stack memory in Java?

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.

Upvotes: 5

Views: 1246

Answers (2)

Aleš
Aleš

Reputation: 9028

You can set the Stack Size of a Java program by using the -Xss argument (or "-XX:ThreadStackSize see Java HotSpot VM Options).

But, once set, the Java stack size cannot be changed dynamically.

Upvotes: 1

mattbdean
mattbdean

Reputation: 2552

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.

Upvotes: 2

Related Questions