• Post Reply Bookmark Topic Watch Topic
  • New Topic

Garbage Collector  RSS feed

 
Emanuel Raúl
Greenhorn
Posts: 5
Chrome Netbeans IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone.

I have a question regarding this issue.

This exercise, can someone explain?

(Ignore the response)

 
Stephan van Hulst
Saloon Keeper
Posts: 7992
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Emanuel,

In the first three lines of the main method, three objects are created. In the next 6 lines, references are being passed around, possibly making any of these three objects eligible for garbage collection (because nothing references the object any more). The exercise asks you after which line exactly one of these three objects has become unreachable.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please QuoteYourSources - tell us where you got this question from.
 
manu lix
Ranch Hand
Posts: 74
Java MySQL Database Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The object becomes eligible when you set the reference variable to null.
 
Stephan van Hulst
Saloon Keeper
Posts: 7992
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
manu lix wrote:The object becomes eligible when you set the reference variable to null.


Not true. Objects become eligible when they're unreachable. "The reference" doesn't actually mean anything.
 
manu lix
Ranch Hand
Posts: 74
Java MySQL Database Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stephan van Hulst wrote:
manu lix wrote:The object becomes eligible when you set the reference variable to null.


Not true. Objects become eligible when they're unreachable. "The reference" doesn't actually mean anything.


Yes, sorry... it's right.
So an object is eligible when no live thread can reach it
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!