finding memory leak in edgewall trac 0.11

rupert.thurner rupert.thurner at gmail.com
Sun Jan 20 06:51:17 EST 2008


On Jan 20, 12:40 pm, "rupert.thurner" <rupert.thur... at gmail.com>
wrote:
> On Jan 19, 10:31 pm, Christian Heimes <li... at cheimes.de> wrote:
>
>
>
>
>
> > Jeroen Ruigrok van der Werven wrote:
>
> > > Hi Christian,
>
> > > -On [20080119 16:16], Christian Heimes (li... at cheimes.de) wrote:
> > >> I forgot one important point in my reply. The GC module contains some
> > >> useful methods for debugging. Check gc.garbage. It should be empty.
>
> > > Yeah, we're messing around with that stuff as well as many other ways of
> > > trying to track issues, but it can really be looking for a needle in a
> > > haystack to be honest.
> > > There's so much output that, I guess, make sense only when you're semi-deep
> > > into the Python internals to even make heads or tails out of it. =\
> > > And even third-party code is not helping much to reduce the clutter and
> > > provide insight.
>
> > Under normal circumstances gc.garbage should be an empty list. In
> > general it's a bad sign if gc.garbage contains lots of objects.
>
> > I found several potential leaks in trac:
>
> > $ find -name \*.py | xargs grep __del__
> > ./trac/versioncontrol/svn_fs.py:    def __del__(self):
> > ./trac/versioncontrol/svn_fs.py:    def __del__(self):
> > ./trac/db/pool.py:    def __del__(self):
>
> > $ find -name \*.py | xargs grep frame
> > ./trac/web/main.py:
> > [...]
> > ./trac/core.py:        frame = sys._getframe(1)
> > ./trac/core.py:        locals_ = frame.f_locals
>
> > I recommend that you either replace __del__ with a weak reference
> > callback or to remove it. Referencing a frame, traceback or f_locals is
> > going to leak, too. You *must* explicitly del every frame and locals
> > variable.
>
> > Christian
>
> many thanks! as the main change was replacing clearsilver with genshi,
> this means one could do the same thing with genshi,http://genshi.edgewall.org/?
>
> $ find -name \*.py | xargs grep frame
> ./genshi/filters/html.py:        'dir', 'disabled', 'enctype', 'for',
...
>
> - Show quoted text -

i forgot to mention that i cannot see any explicit sys._getframe(), or
__del__ in the genshi code, while the ones in trac-core seemed to be
there in 0.10.4.

rupert



More information about the Python-list mailing list