• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Circular references

 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

is it right that in such a situation the two object can only be eligible for garbage collection when both the references are set to null?
from the veiwpoint of the exam is there anything else i need to know about circular references and garbage collection.
 
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The garbage colletor in JVM does resolve circular references.
Let's say Obj1 and Obj2 can not be accessed from any other references, but they can reference each other, then the garbage collector will release the memory occupied by those objects.
Hope this helps
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You may want to have a look at this article about garbage collection:
Reference Objects and Garbage Collection
HIH
 
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It would be helpful if we were to know why we should look at this reference. Is the current explanation not sufficient?
 
Valentin Crettaz
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Pres,
it never hurts to know more than expected. See that as a sort of computer culture or something.
Sure the explanation is sufficient, but it is up to you if you want to look under the hood or not.
Nothing is mandatory, I gave the link, if you think you don't need it, then don't read it. If you think you got the meaning of circular references and garbage collection with the answers you read then fine, otherwise, take a look at hte link.
 
Pres Brawner
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Valentin,
I think you're missing the point. Look carefully at your initial post. It can be viewed from two perspectives.
One: If you know the answer already provided is correct and want additional information, see this link.
Two: The original answer was incorrect. For the correct answer, follow this link.
I know you know what you mean. Please just let the rest of us in on it.
Thanks.
 
Valentin Crettaz
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Whatever,...
I didn't mean to be misleading... If it is how you feel, then I apologize. It's just that sometimes I don't take enough time to answer a question and the quality of my answer is not that good.
Usually when an answer is not sufficient, not accurate or wrong, I say it loud, oh yeah, and I give my explanation. Otherwise if I just let go, it means that the answer is correct (according to me) but, here you go, here is some more information about the question... So my intention was the first perspective you gave, but how could you know, you're not a mind reader
 
Samith Nambiar
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Shivaji Marathe:
The garbage colletor in JVM does resolve circular references.
Let's say Obj1 and Obj2 can not be accessed from any other references, but they can reference each other, then the garbage collector will release the memory occupied by those objects.


is this absolutely right ??? ... if so i dont seem to understand how the GC will release the memory when infact there is a reference for each of the two objects
thanx for the link Valentin
/SAmith
 
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi samith,
there r ways to get rid of circular ref problem for GC. one way i know is something called "train algorithm" but i have forgotten how exactly it works. you can refer to
Artima.com
which can give u some more idea about garbage collection.
regards
maulin.
 
Shivaji Marathe
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Samith :
The article that valentin provided a link to, inlcudes a very nice diagram representing how objects that reference each other, but can not be referenced from any other objects are eligible for garbage collection.
HTH
 
Samith Nambiar
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yup i had a look at that ... it helped ... thanks
/SAmith
 
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Valentin ,
thanks for the good link! I had always wanted to learn about weak references, and now I learned something.
Thanks,
Rob
 
"Don't believe every tiny ad you see on the internet. But this one is rock solid." - George Washington
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic