[Mailman-Developers] Re: Huge qrunner process
Thomas Wouters
thomas@xs4all.net
Fri, 8 Dec 2000 09:49:35 +0100
On Thu, Dec 07, 2000 at 12:51:49PM -0500, sigma@pair.com wrote:
> There is a definite memory leak or inefficiency somewhere. Just the following
> fragment of code, edited from senddigests, is enough to send the memory usage
> sky-high:
>
> def main():
> for listname in Utils.list_names():
> mlist = MailList.MailList(listname, lock=0)
> del mlist
>
> The "del mlist" doesn't help.
> Is there a way to tell if Python is deleting the MailList object when mlist
> gets reassigned, so I can find out if there is a leak each time a list is
> loaded? Otherwise it's just inefficient memory usage in proportion to the
> size of config.db
Python uses reference-counting, so the mailinglist should go away as soon as
all references to it go away. However:
python -i bin/withlist mailman-devel-test
>>> import sys
>>> sys.getrefcount(m)
12
There are 12 references to the mailinglist object. One is the argument
passed to 'getrefcount', one is the local variable 'm', but the other 10 are
unaccounted for. I think it's safe to say there's a reference cycle in there
somewhere ;) The easiest way to fix this is probably to install Python 2.0
with the garbage collector. It's a new feature, which tries to collect as
much cyclic garbage as possible. If anything, it can help figure out where
those cycles exist.
Barry ? Would it be a good idea, in the mean time, to explicitly break the
cycle in some way, say 'mlist._release()' or some such, document it as
internal, and use it wisely in senddigests/qrunner ? That would require
finding the cycles, of course ;P
--
Thomas Wouters <thomas@xs4all.net>
Hi! I'm a .signature virus! copy me into your .signature file to help me spread!