File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Khalid: GC ?

 
Cathy Song
Ranch Hand
Posts: 270
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"If object obj1 can access object obj2 which is eligible for garbage collection, then obj1 is also eligible for garbage collection".
I dont understand this. What is obj1 has a reachable reference, then obj2 wont be eligible anymore right?
 
Harwinder Bhatia
Ranch Hand
Posts: 150
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The assumption here is obj2 is eligible for Garbage collection. This means that it cannot be referenced by any active part of the program. But it can be referenced by obj1. This means that obj1 cannot be referenced by any active part of the program either, which makes obj1 eligible for Garbage collection too.
If obj1 is reachable through a reference, then obj2 will be reachable too and hence no longer eligible for gc.
Maybe Marlene can explain it better.
Thanks
Harwinder
 
Marlene Miller
Ranch Hand
Posts: 1392
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Harwinder, your explanation if very clear and logical.
 
Alton Hernandez
Ranch Hand
Posts: 443
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In other words, a circular reference does not prevent an object from being GC'd.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic