Results 1 to 4 of 4
Thread: Heap or Stack
- 01-17-2011, 02:23 AM #1
Member
- Join Date
- Jan 2011
- Posts
- 2
- Rep Power
- 0
- 01-17-2011, 06:15 AM #2
First of all, Eclipse has nothing to do with heap or stack storage.
Then, to keep it very simple, your objects live on the heap and you methods live on stack.
The variables which you declare inside you class are nothing but the instance variables. Your instance variables live inside the objects created, means on the heap.
The variables declared inside the methods are local variables. And your local variables live inside the methods [as they live as long as the method is alive] which means on the stack.
However, the object references live depending on where they have been declared. Object reference declared as instance variable lives inside the class object on the heap, whereas, the object reference declared inside the method lives on the stack along with method. No matter where the object references are declared, the object always live on the heap.
The method parameters are also considered as local variables and so, they live on stack as well.
Now can you figure out on your own which thing in your code lives where?
Hope that helps,
GoldestJava Is A Funny Language... Really!.gif)
Click on * and add to member reputation, if you find their advices/solutions effective.
- 01-17-2011, 06:23 AM #3
Java Is A Funny Language... Really!.gif)
Click on * and add to member reputation, if you find their advices/solutions effective.
- 01-17-2011, 06:14 PM #4
Member
- Join Date
- Jan 2011
- Posts
- 2
- Rep Power
- 0
Similar Threads
-
Increasing heap/stack size (MacOSX)
By CapsLoc in forum New To JavaReplies: 3Last Post: 12-13-2010, 10:52 AM -
The Stack and the Heap
By al_Marshy_1981 in forum New To JavaReplies: 9Last Post: 06-25-2010, 09:45 AM -
no heap space... need more heap
By anupam.kumar in forum Advanced JavaReplies: 3Last Post: 02-08-2010, 04:42 PM -
Stack implementation
By jefrazie in forum New To JavaReplies: 3Last Post: 10-07-2009, 12:59 PM -
Help with heap and stack
By coco in forum Advanced JavaReplies: 1Last Post: 08-06-2007, 02:21 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks