[ZODB-Dev] Investigating a Zope reference leak... tracking object creation

Chris Withers chris at simplistix.co.uk
Wed Feb 2 05:09:56 EST 2005


Ben Last (ZODBDev) wrote:
>>> <img tal:replace="structure 
>>> python:here.scripts.getGraphic(here,environment,'myimage.gif',...)"/>
>>
>> And does this provoke your leak?
> 
> That I don't know, that's why I'm trying to track instance creation :)  

Why are you bothering to do that? This goes back to my original 
debugging suggestion: you're aiming to get the simplest possible test 
case which ALWAYS shows a leak...

>> Are any arguments passed which aren't simple strings?
> 
> Yes.  The environment, for instance, is a "dictish object" which means 
> that one can access the members as attributes as well as using dict 
> syntax.

Why are you bothering with this? And what does the code being this 
object look like? Funny business like this is often the source of leaks...

>>>     if flash is None:
>>>         flash = getattr(environment,'flash',False)
>>
>> What's flash?
> 
> b) a boolean (strictly, something that evaluates True/False in Python)

Okay, so when is it not either the True or False singleton?

> This is used in many places, and there appear to be no leaks of them at 
> all.

That's like saying "guns are used in many places, and no-one has shot 
themselves in the foot". It doesn't mean there's nto blood pouring out 
of your foot ;-)

> We use the dictish objects because otherwise, when writing Python 
> in the context of ZPT, one needs always to be aware of when one's 
> dealing with an object (most cases) or a dict (edge cases) 

Why?

> number of times that caused problems was growing.  We adopted an idiom 
> by which multiple-value results are always returned as objects.

I'd suggest that is "wrong". The most common way to do this is to store 
things in a simple python dictionary and return that.

>> What's "doTag" ?
> 
> A method 

A method of what? Where's the code?

> that takes the parameters (all are simple except img) and 

And what is img?

>>>     except AttributeError:
>>>         pass
>>
>> Why pass? might be interesting to see what throws attribute errors and 
>> why?
> 
> It would be on the test site.  In the production environment, problems 
> like this would get reported via Zope error pages to customers, who 
> aren't interested in them!

Jeez, talk about sweeping crap under the carpet... if you're getting 
attributeerrors, find the source, don't just ignore them...

>>>     if swftarget:
>>>         graphic = flashOverride(here,swftarget,graphic)
>>
>> What does this do?
> 
> Looks to see if there's a flash file that can be used to replace the 
> graphic.  In the current test version of the site, all the Flash files 
> have been removed whilst we've been tracking the leak, so in effect it's 
> a no-op.

Then take it out, see if the leak goes away... There's always Undo to 
bring it back later...

Chris

-- 
Simplistix - Content Management, Zope & Python Consulting
            - http://www.simplistix.co.uk


More information about the ZODB-Dev mailing list