>on 30/3/01 20:04, Franco Vaccari at vaccari /AT/ dsterra .D.OT univ.trieste.it wrote: > >>>> Definitely yes (but in Basic...). I try to destroy them on quit as >>>> once discussed on the list. Of course when exception occur, the >>>> destroy method is not called. >>> >>> I think "secret" is here. >>> >> >> So, do you think that there could be a solution, or circular >> references should be just avoided as evil? I feel bad just when >> thinking of removing them from everywhere around... > >Actually I have found and sent to REAL VERY simple project which show bug in >garbage collection in case of circular references. Without ANY plugin! > >But in that bug to get it developer need during debugging look on object >value in window "Values". Then RB crashes on next restart. > >So, yes, looks like circular refs give us not needed headache, at least now...
Circular references aren't evil, but they do require special consideration. As I understand it, they are a problem for any software that uses reference counting to manage memory -- so I certainly don't depend on RB to clean up objects involved in such alternative relationships.
Generally, it's okay to make a circular reference when one of the objects involved is a control, because controls have Close events that always fire, providing you with an opportunity to break the reference chain. I use such references quite frequently in factoring my code between objects and editable views of those objects.
Otherwise, I try to avoid them as much as possible. Mostly, I find that unintended circular references are a sign that I need to refactor some code.
Charles Yeomans ©2001 Charles Yeomans |