• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Stack Memory

 
Mohtashim Shaikh
Ranch Hand
Posts: 43
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to know what is the stack size i.e. -Xss my java program is running with.
Is there a way to find that out from inside the java program code and outside of it.

Regards,
Mohtashim
 
KayCee Clark
Greenhorn
Posts: 13
Java Oracle Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have not had experience looking at this but here is what I found.

I tried JConsole ( in your bin directory ). That gives you a lot of information about various pools, but no specific mention of stack.

I found something that indicates setting the stack size higher may be a problem because each thread gets that amount of space and you can actually run out of memory faster.

I found this HotSpot parameter documentation that mentions some default sizes.

-XX:ThreadStackSize=512 Thread Stack Size (in Kbytes). (0 means use default stack size) [Sparc: 512; Solaris x86: 320 (was 256 prior in 5.0 and earlier); Sparc 64 bit: 1024; Linux amd64: 1024 (was 0 in 5.0 and earlier); all others 0.]

on this page
http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html

There is another parameter for Solaris only on that page as well.

Have fun !

 
KayCee Clark
Greenhorn
Posts: 13
Java Oracle Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A little bit more, but I don't (yet?) see any direct way to just look at stack size programatically.

A good page on tuning, including memory, from Oracle.

http://java.sun.com/performance/reference/whitepapers/

tuning.html


I found this page where the author provides his code

and his reasoning behind the test and calculations.

http://www.odi.ch/weblog/posting.php?posting=411


Also, some code here, but again, nothing specific for

stack.

http://viralpatel.net/blogs/2009/05/getting-jvm-heap-s

ize-used-memory-total-memory-using-java-runtime.html
 
Mohtashim Shaikh
Ranch Hand
Posts: 43
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Thank you for your reply. However, what i am looking for is to read whatever the current set -Xss (stack sie) is for a particular JVM i.e PID be it default or set eplicitly from inside a unix shell script or a java program inorder to setup a monitoring alert script.

A third-party tool may also come handy only if we can use its API inorder to read the stack size inside the unix shell script or a java program.

Kindly help !!!

Regards,
Mohtashim
 
Campbell Ritchie
Sheriff
Pie
Posts: 47300
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving discussion as too difficult for "beginning".
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no (easy) way of getting the stack size for threads in a Java process.

There is for example no system property that you could get with System.getProperty(...), and even the JVM TI (an API for debugging and profiling tools to get information from and control a running JVM) doesn't seem to have any way to get the stack size.

Why do you need this?
 
Mohtashim Shaikh
Ranch Hand
Posts: 43
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The pmap command for solaris tells us the current stack usage for a JVM. What is th use of the current stack size that it displays when there should be no way to find the upper limit of stack which that JVM is allowed to run with.

This deprives us for writing a script that alerts as the stack size reaches more than 90% of allocated stack size. Thats why i need it.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic