[ZODB-Dev] zodb-3.4.0 leaks ZEO.cache.Entry objects?
Chris Bainbridge
chris.bainbridge at gmail.com
Thu Aug 4 13:43:33 EDT 2005
On 03/08/05, Tim Peters <tim at zope.com> 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()
More information about the ZODB-Dev
mailing list