Val SCJP <BR>going for SCJD
Wait a minute, I'm trying to think of something clever to say...<p>Joel
"JavaRanch, where the deer and the Certified play" - David O'Meara
Wait a minute, I'm trying to think of something clever to say...<p>Joel
"JavaRanch, where the deer and the Certified play" - David O'Meara
Originally posted by Cindy Glass:
Joel
x and tmp are not objects (they are variables) and will [b]NEVER be ready for the gc(). They will die with the stack.
The x does not reference an object, it references a constant literal primitive that happens to be an int. That literal will NEVER be ready for the gc(). It will be unloaded when the class is unloaded.
[/B]
Originally posted by Cindy Glass:
Only [b]objects on the heap get garbage collected. The references that tmp holds during each iteration are to 2 objects on the stack. They will get garbage collected.
[/B]
Wait a minute, I'm trying to think of something clever to say...<p>Joel
3.5.2 Java Virtual Machine Stacks
Each Java virtual machine thread has a private Java virtual machine stack, created at the same time as the thread. A Java virtual machine stack stores frames (�3.6).
3.6 Frames
A frame is used to store data and partial results, as well as to perform dynamic linking , return values for methods, and dispatch exceptions.
A new frame is created each time a method is invoked. A frame is destroyed when its method invocation completes, whether that completion is normal or abrupt (it throws an uncaught exception). Frames are allocated from the Java virtual machine stack (�3.5.2) of the thread creating the frame. Each frame has its own array of local variables (�3.6.1), its own operand stack (�3.6.2), and a reference to the runtime constant pool (�3.5.5) of the class of the current method.
"JavaRanch, where the deer and the Certified play" - David O'Meara
Wait a minute, I'm trying to think of something clever to say...<p>Joel
Don't get me started about those stupid light bulbs. |