• Post Reply Bookmark Topic Watch Topic
  • New Topic

GC  RSS feed

 
Thiru Thangavelu
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought the answer is after //4. But the answer given is never GC. why?
After which line will the object created at line XXX be eligible for garbage collection?
 
Jose Botella
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because the object pointed by b is also pointed by c, and c is returned.
 
Anthony Villanueva
Ranch Hand
Posts: 1055
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
getObject() is returning a reference to the object you created at line XXX. Since the object is still referenced, it is not yet eligible for garbage collection.
HTH
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!