[Python-Dev] We got leaks!

Kevin Jacobs jacobs@penguin.theopalgroup.com
Fri, 6 Dec 2002 18:25:57 -0500 (EST)


On Fri, 6 Dec 2002, Kevin Jacobs wrote:
> I'm in the process of isolating the other leak that hits both the Python and
> C verions of datetime in the test_pickling() function, though I suspect that
> may be other incarnations of the above problem.

Here it is:

  import sys
  import cPickle

  dumped = cPickle.dumps(object())
  for i in range(10):
    cPickle.loads(dumped)
    print '*' * 10, 'total refs:', sys.gettotalrefcount()

With output:
  ********** total refs: 10929
  ********** total refs: 10930
  ********** total refs: 10931
  ********** total refs: 10932
  ********** total refs: 10933
  [...]

The leak occurs in cPickle.loads, but not in pickle.loads.  It also does not
depend on binary or non-binary mode of dumps().  It seems to require a
new-style object to occur, but not one that implements a custom hash
function as in the previously reported leak.

This is all I have time for this evening... If the case(s) are not cracked
tomorrow, I'll take a stab at dissecting the responsible C code.

Enjoy!

-Kevin

--
Kevin Jacobs
The OPAL Group - Enterprise Systems Architect
Voice: (216) 986-0710 x 19         E-mail: jacobs@theopalgroup.com
Fax:   (216) 986-0714              WWW:    http://www.theopalgroup.com