[ZODB-Dev] memory or cache leak?

Jeremy Hylton jeremy@zope.com
Thu, 1 Nov 2001 15:35:25 -0500 (EST)


>>>>> "MP" == Michel Pelletier <michel@zope.com> writes:

  >> If I change the arguments to cacheMinimize() and cacheFullSweep()
  >> from 0 to 4, the memory usage seems to be capped at 37MB.

  MP> Hmm, that's interesting.  I just tried that too, and it works
  MP> for me.

Jim mentioned this in person a week or two ago (that any value < 3 is
treated as 0).  I thought I mentioned that on the list earlier, but I
could be istaken.

  MP> I think the problem is, when you pass 0 as a argument it runs in
  MP> the following code in cPickleCache.c:

  MP>   if (dt < 0) dt=0; else dt /= 3;

  MP> which of course sets dt to 0.  This value is then passed into
  MP> gc_item for each object in the cache which does nothing if dt is
  MP> logicaly false (see line 155 in cPickleCache.c).  Any positive
  MP> value for dt will result in gc_item actually cleaning up
  MP> objects.

Line 155!  I was trying to find where in the code it was used, but
missed this.

Perhaps this --

if (dt < 0) 
    dt=0; 
else 
    dt /= 3;

-- should become this --

if (dt < 0)
    dt = 0;
else {
    dt /= 3;
    if (dt == 0)
        dt = 1;
}

I can't imagine anyone depends on 1 or 2 being treated as 0.

Jeremy