• Post Reply Bookmark Topic Watch Topic
  • New Topic

OutOfMemoryError in JVM stack  RSS feed

 
manish ghildiyal
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

JVM specs say following about JVM stack:

The following exceptional conditions are associated with Java Virtual Machine stacks:

If the computation in a thread requires a larger Java Virtual Machine stack than is permitted, the Java Virtual Machine throws a StackOverflowError.

If Java Virtual Machine stacks can be dynamically expanded, and expansion is attempted but insufficient memory can be made available to effect the expansion, or if insufficient memory can be made available to create the initial Java Virtual Machine stack for a new thread, the Java Virtual Machine throws an OutOfMemoryError.


Suppose I have used all of the stack memory in a running program. Now if program tries to add a new frame to JVM stack then would I get StackOverflowError or OutOfMemoryError?

Manish
 
Campbell Ritchie
Marshal
Posts: 56599
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It depends whether you run out of stack space or heap space first. I think in the scenario you presented, a stack overflow error will probably occur first.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!