• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

cyclic reference in gc

 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wanted to know how cyclic references are resolved during garbage collection.
Lets we have a circular linked list
class A has reference to B
class B has reference to C
class C has reference to A

If I make A null, and assume it is garbage collected, will C and B be GCed as well?
Is there any good doc which explains garbage collection in case of cyclic references
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is entirely up to JVM implementation, so you'd have to consult the docs for a particular JVM.

Cyclical references would be a problem if GC's used reference counting as their algorithm to identify unused object. However, I don't think any do - reference counting has big performance issues, as well as the possibility of deadlock you've noticed.
 
Vasim Patel
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Paul

Are you aware of any link to such documentation?

Also, I wanted to know more about the various algorithms that JVM used for GC like mark and sweep. Are there any good docs? or any books worth buying?
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sun has docs - have a hunt around their site. I don't know of any books - this is quite an advanced topic though. I can't imagine many programmers will need this sort of info for their day-to-day activities, so I don't know how well covered by third party books it will be.
 
reply
    Bookmark Topic Watch Topic
  • New Topic