Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Heap and Stack

 
Girish Prabhudesai
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anybody tell me difference in memory stack and heap being used in Java JVM?
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Basically, the stack is where local variables are kept -- ints, floats, doubles, and references to objects -- while the heap is where objects themselves are allocated. So variables on the stack can point to objects on the heap.
Does this answer your question?
 
Girish Prabhudesai
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the answer.
 
VIJAY Yadlapati
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All Objects are stored on Heap.
All variables and address of object inHeap are stored in Stack.
 
VIJAY Yadlapati
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All Objects are stored on Heap.
all variables and addresses of objects are stored on Stack.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic