[Zope] Posible memory leak?

Gabriel Genellina gagenellina at softlab.com.ar
Fri Nov 28 23:33:59 EST 2003


At 27/11/2003 21:17, you wrote:

>I added a step in my manage_addTopic() script like
>this to make a local reference to the "View" attrib I'm
>trying to acquire:
>
>ob = Topic(...)
>ob.ViewAlias = self.View
>self._setObject(id, ob)
>ob = self._getOb(id)
>
>View is a PersistentMapping, so I presume it will act like
>a normal mutable Python object (so when I make changes
>to its contents, they'll show up in the alias).  I'll have
>to test this, anyway, to make sure, of course.
>
>In the __setstate__ method, Topic computes using the
>ViewAlias which is a local attribute:
>
>for view in self.ViewAlias.keys():
>         #... do some stuff with this view info
>         pass

Is this correct? Or there is a memory leak here?
In a previous post 
http://mail.zope.org/pipermail/zope/2002-January/107054.html Max M 
maxm at mxm.dk said:

>If your item is subclassing persistent you should expect them to stay in
>the zodb. And then you should not add them to a list in your own
>product, but create a subclass of ObjectManager and use the _setObject()
>method to add the item instances.
>
>Else your item class should not subclass persistent.
>
>If you want to do it your way by adding item instances to a list in your
>product you should also be aware that every time your product is
>changed, or even one of the item instances, the whole object is written
>to the Data.fs again. Leading to a bloated Data.fs ... if you don't pack
>it regularly.
>
>But doing something like that with that many objects is the wrong way to
>use the zodb.

 From this and other sources I've been told *not* to store a Persistent 
object as an attribute of another object, as this would cause a memory 
leak. But maybe a PersistentMapping is specially crafted? I dont see 
anything special in its source.

Perhaps the enlightened people could explain the rules to avoid memory leaks...


Gabriel Genellina
Softlab SRL




More information about the Zope mailing list