On 03/08/05, Tim Peters <[EMAIL PROTECTED]> wrote: 
> The refcount on Entry keeps growing.  I suspect, but don't yet know, that
> this is because FileCache._makeroom()'s 
> should have another line:
> 
>             if e is not None:
>                 del self.key2entry[e.key]
>                 self._evictobj(e, size)

I tried this and it worked - the Entry objects disappear, along with
tuple. The number of lists is still growing though.

With your example I get linear unbounded growth with
BTrees._OOBTree.OOBucket and list objects. I'm using memprof from
http://svn.navi.cx/misc/trunk/python/memprof/. Script:

import sys
import random
import logging
import gc
logging.basicConfig()

import ZODB
from ZODB.config import storageFromString
from ZEO.cache import Entry

import BTrees
from BTrees.OOBTree import OOBTree
import transaction

import memprof
sampler = memprof.Sampler()
sampler.run()

config = """\
   <zeoclient>
   server localhost:12345
   cache-size 32KB

   </zeoclient>
"""
#   client glimmer
st = storageFromString(config)
db = ZODB.DB(st)
cn = db.open()
rt = cn.root()

if "tree" not in rt:
   rt["tree"] = OOBTree()
   transaction.commit()
tree = rt["tree"]

N = 100000
for i in xrange(N):
   j = random.randrange(1000000000)
   tree[j] = str(j)
   transaction.commit()

   sampler.run()
   typeMap = {}
   for obj in gc.get_objects():
      if hasattr(obj, '__class__'):
         t = obj.__class__
      else:
         t = type(obj)
      t = str(getattr(t, '__name__', t))

      typeMap[t] = typeMap.get(t, 0) + 1

   l = []
   for name,count in typeMap.iteritems():
      l.append((name, count))
   l.sort(lambda x,y: cmp(y[1],x[1]))
   print 'OOBucket (refcount=%d, objects=%d)     list (refcount=%d,
objects=%d)'%(
      sys.getrefcount(BTrees._OOBTree.OOBucket),typeMap['OOBucket'],
      sys.getrefcount(list),typeMap['list'])

print
db.close()
_______________________________________________
For more information about ZODB, see the ZODB Wiki:
http://www.zope.org/Wikis/ZODB/

ZODB-Dev mailing list  -  ZODB-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zodb-dev

Reply via email to