aspose file tools
The moose likes Performance and the fly likes Stack Space Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Performance
Reply Bookmark "Stack Space" Watch "Stack Space" New topic
Author

Stack Space

Will Myers
Ranch Hand

Joined: Aug 05, 2009
Posts: 285

I have been asked to find out how much stack space a function will use and have no idea how to do this, any pointers? The function is:

Will Myers
Ranch Hand

Joined: Aug 05, 2009
Posts: 285

I have done some research and have come up with:

long = 64 bit * 2,
int = 32 bit * 2,

so 192 bits or 24 bytes on the stack total, is this correct? It's assuming the return and param are not counted....
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 9939
    
    6

I don't think so...More than just the variables are stored in the stack, but I don't think you can find out what exactly. It may even be dependent on which exact implementation of the JVM you are using.

A better answer would be "Why does it matter?"


Never ascribe to malice that which can be adequately explained by stupidity.
Mike Simmons
Ranch Hand

Joined: Mar 05, 2008
Posts: 2770
    
    2
The javap tool can tell you this, using the -verbose option. At least, it can tell you about what the compiled class file says the stack usage should be. It's possible for HotSpot to modify this at runtime, I suppose. But I doubt it will change too much. Unless you use the funky JVM options like -XX:+DoEscapeAnalysis.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Stack Space
 
Similar Threads
won't let me input integer values
Counting chars during file read.
how to split a number into two multipliyers
tail recursion
How to pass a javascript variable on a jsp to a servlet