• Post Reply Bookmark Topic Watch Topic
  • New Topic

Stack Space  RSS feed

 
Will Myers
Ranch Hand
Posts: 417
Java jQuery Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 417
Java jQuery Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12529
48
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?"
 
Mike Simmons
Ranch Hand
Posts: 3090
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!