views:

626

answers:

4

The idea would be to help determine the optimum stack size for a given Java application.

One thing that could be done with this information create a range-table of stack sizes which the threads could modify as they exit and which could be dumped periodically and at application exit.

EDIT: This is in the context of running on customer machines with real workloads which I can't get profiler access to.

EDIT2: In response to one answer, at (IIRC) 256Kb per thread, I have wondered for a while now how close to the reality of what's need that is (I also wonder if it's not very relevant because it's allocated on demand). We have an application server which is based on message passing and highly threaded and runs on everything from an ARM handheld to octo-core Linux, to midrange and mainframes - it would be good to have a feeling where (and if) we can trade stack space for heap on systems with many message handlers.

There are some similar questions which are of interest, but they are native/os-specific:

A: 

Use JConsole-- you likely already have it: http://java.sun.com/j2se/1.5.0/docs/guide/management/jconsole.html http://openjdk.java.net/tools/svc/jconsole/

Cuga
I had thought about that (actually JVisualVM is better), and I use JProfiler... but this is in the context of running on customer machines with real workloads which I can't get profiler access to.
Software Monkey
A: 

Can you say why need to optimise your stack size? Or this this something you just want to try?

Peter Lawrey
Edited question with why I am curious about this.
Software Monkey
+1  A: 

Stack memory will be hard to obtain.

Best you can do, and quite easily, is JVM memory usage via MemoryMXBean.

Yuval A
A: 

I think you can do that with the brand new VisualVM too.

Davide
Per my comment to Cuga's answer from May 5: "I had thought about that (actually JVisualVM is better), and I use JProfiler... but this is in the context of running on customer machines with real workloads which I can't get profiler access to."
Software Monkey
Interesting - JVisualVM is bundled with Java 6 - I didn't know that it is also distributed via the web. The plugins look quite useful.
Software Monkey