[Zope] Posible memory leak?

Dylan Reinhardt zope at dylanreinhardt.com
Sat Nov 29 11:36:05 EST 2003


On Fri, 2003-11-28 at 20:33, Gabriel Genellina wrote:
> 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.
> >
> 
>  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. 

Depends on what you mean by "memory leak" I supposed.  If you *do* store
persistent objects within persistent objects, you'll typically save a
new copy of the parent object each time a change is made to one of the
children. That can lead to some serious ZODB bloat... but then again,
that's something a cron job can mostly take care of for you.  

To me, a memory leak is when your application allocates RAM and doesn't
release it.  How you store sub-objects *will* have memory usage
implications, but it has little to do with persistence.  For example, if
you have an indexed collection of sub-objects, using a BTree for storage
will be *vastly* more efficient than using a vanilla dictionary.

HTH,

Dylan




More information about the Zope mailing list