On Apr 11, 2007, at 09:29 UTC, Stephen Dodd wrote:

> Are circular references never destroyed and garbage collected?

Correct, because RB doesn't have a garbage collector (and I for one am
quite happy that it doesn't).

> EggCarton object contains 12 Egg objects (as properties) Each Egg
> contains a reference to the parent EggCarton
> 
> If my program creates and destroys EggCartons containing Eggs, will I
> 'leak' memory unless I use WeakRef?  (Assume only the EggCarton 
> references Eggs.)

Well, your programs create and *release* EggCartons, but they're not
destroyed (nor are the eggs they contain) because the eggs have not
released them.  So yes, you will leak memory... unless you first call a
Close (or ReleaseData or whatever you want to call it method) on your
EggCartons before releasing them, which method can nil all its
references to the eggs, breaking the cycle and allowing the objects to
be destroyed.  Or, as you say, you could use WeakRef.

Best,
- Joe

--
Joe Strout -- [EMAIL PROTECTED]
Verified Express, LLC     "Making the Internet a Better Place"
http://www.verex.com/

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to