Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Garbage collection eligibility

 
Fantine Ponter
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please will someone straighten out my confusion.
I've put comments into the code below to show where I need answers/direction:

 
Henry Wong
author
Marshal
Pie
Posts: 21403
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow... there are lots of questions here... almost too many. Anyway, I guess I'll take one of the methods.




Henry
 
Henry Wong
author
Marshal
Pie
Posts: 21403
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, I'll take another small method too...



Henry
 
Fantine Ponter
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Henry, I'll try to drum that into my head. I guess I'll wait for the clarification of the main method before I can say I finally understand it all now...
 
Fantine Ponter
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry, to answer your question:
***> BTW, what do you mean by "another useless reference"?

As I understand it, there seems to be no point in creating a reference if it has no object to reference, hence 'useless reference'.

I apologize for asking so many questions. The better I can understand each statement, and recognise the statements for what they are, the fewer questions I'll be asking in my very slow learning curve.

Thanks for your informative answers to my questions. I really appreciate it.
 
Henry Wong
author
Marshal
Pie
Posts: 21403
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, some more code explained (from the main() method) ...

 
Fantine Ponter
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
okay, now the pieces are starting to fall into place. Thank you!
 
Fantine Ponter
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By George, I've got it! Thanks Henry
No more questions.
 
Arend van der Kolk
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Fantine,

Years after you posted it, ;-)

Thank you for bringing the whole exercise onto coderanch, it is a good unraveling of the lesson in the book i have been doing.

And Henry, thank you for the explanation and teachings.

cheers,

Arend
 
Elim Banda
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't understand this question doesn't everything pop of the stack eventually. What is the essence of the question.
 
Dave Tolls
Ranch Hand
Posts: 1755
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Elim Banda wrote:I don't understand this question doesn't everything pop of the stack eventually. What is the essence of the question.


Yes, but objects exist on the heap.
The thing that pops off the stack is the reference, not the object itself.
It's the garbage collectors job to monitor whether an object on the heap has any references pointing at it.  If it doesn't then it is classed as eligible for garbage collection.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic