[Zope] Sessions and RAM cache managers causing memory leak

Jamie Heilman jamie at audible.transient.net
Mon May 17 13:13:05 EDT 2004


Richard Ettema wrote:
> Some of the dtml methods being cached have dtml namespace cache keys set 
> (no request vars are used) and appear on all accounts to being working 
> as expected, with the expected number of enteries for these dtml 

Thats could be the problem.  If you pass the wrong thing to the dtml
namespace cache keys you will end up in a world of pain.  I suggest
adding some debugging statements inside ZCacheable_set or
ZDocumentTemplate_afterRender to see what that keywords dictionary
you're passing in actually looks like to the the RCM.  If the RCM ends
up calling str() on any objects that get repr'd like
<Foo instance at 6a3463> then you're going to see a lot of cache
misses and spurious growth as your python process grows in size and
relocates its objects in memory.  This is the same problem facing
PageTemplates that I wrote about last year in
http://marc.theaimsgroup.com/?l=zope&m=105460381811223&w=2

I solved it by writing a cache manager that gave the user more control
over how cache keys were handled.  Many times a simple str() is just too
simplistic.  The good news is you're still using 2.6 so you could use
my cache manager (MemoryCache), the bad news is it requires patches to
the core caching api (backwards compatible with everything I've tested
though) and python 2.2.x not 2.1.x and not 2.3.x.  And it doesn't work
in 2.7 yet for various and sundry issues to do with PageTemplateFile
and its management interfaces.  But first things first, add some
debugging and find out if the behavior you're seeing is actually
attributeble to the same thing I mentioned above.

-- 
Jamie Heilman                     http://audible.transient.net/~jamie/
"You came all this way, without saying squat, and now you're trying
 to tell me a '56 Chevy can beat a '47 Buick in a dead quarter mile?
 I liked you better when you weren't saying squat kid." -Buddy



More information about the Zope mailing list