[Tutor] Object attributes surviving deletion

Jeff Younker jeff at drinktomi.com
Fri Jun 27 00:32:23 CEST 2008

On Jun 26, 2008, at 2:59 PM, Shrutarshi Basu wrote:

>           self.modules.append(DisplayModule(self.img_map,
> (self.xOrigin, self.yOrigin), self.rows, self.columns, gram,
> self.type))
> As you can see, not only do I delete gram, I also blank out everything
> that should be cleared. I have to manually clear gram.database because
> otherwise it keeps the data from previous calls to that function. I
> don't understand why this should be. DisplayModule is a class that
> packages and organizes the data into a convenient form.
> Thanks,

You've passed gram to DisplayModule, and you've added DisplayModule
to a collection.  My guess is that display module still holds a  
reference to gram,
and gram won't be collected until DisplayModule clears that reference.

As an additional aside python doesn't guarantee that objects will
be released as soon as they are unreachable.  They can hang
around for a while until a garbage collection is triggered.


More information about the Tutor mailing list