[Numpy-discussion] Interesting memory leak

Fernando Perez fperez.net at gmail.com
Fri Aug 18 18:52:57 CDT 2006


> This leak is caused by add_docstring, but it's supposed to leak. I wonder if
> there's a way to register some kind of on-exit handler in Python so that
> this can also be cleaned up?

import atexit
atexit.register(your_cleanup_function)

whose api is no args on input:

def your_cleanup_function():
  do_whatever...


You could use here a little extension function which goes in and does
the necessary free() calls on a pre-stored list of allocated pointers,
if there's more than one (I don't really know what's going on here).

Cheers,

f




More information about the Numpy-discussion mailing list