freepooma-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

reference loop with updaters


From: Julian Cummings
Subject: reference loop with updaters
Date: Tue, 10 Apr 2001 16:37:33 -0700

Hi All,

I got a little sidetracked today when I noticed that a few
of the NewField test codes (BasicTest1 and FieldTour1)
dump core at the end, during object cleanup.  This happens
because the Pool class detects that not all the pooled memory
has been freed.  After a fair bit of detective work, I have
determined that this is due to a reference-counting loop
between Fields and Updaters.

When you add an Updater to a Field, the Updater stores a
copy of the Field in UpdaterRetargetBase.  The Updater is
added to an UpdaterList stored in the FieldEngineBase
base class of the FieldEngine inside the Field.  Thus, there
is a circular loop in the reference counting.  When the Field
is destroyed at the end of the program, it calls the destructor
for its FieldEngineBase.  The FieldEngineBaseData referred
to by the FieldEngineBase does not get destroyed, however,
because there are outstanding references to it which correspond
to the copies of the Field in each Updater.

I think this is a fairly significant problem that should be fixed.
I'm not sure what the proper solution is though.  Calling
removeUpdaters() in the Field destructor causes an infinite
recursion.  Perhaps this recursion could be broken by making
the FieldEngine the subject of an Updater, rather than the Field.
Would that work?  I'm going crazy just thinking about it...

-- Julian C.


--
Dr. Julian C. Cummings                       E-mail: address@hidden
California Institute of Technology           Phone:  626-395-2543
1200 E. California Blvd., Mail Code 158-79   Fax:    626-584-5917
Pasadena, CA 91125


reply via email to

[Prev in Thread] Current Thread [Next in Thread]