[SciPy-User] Potential KDTree memory leak

Pierre Lamon pierre.lamon@bluebotics....
Thu Mar 11 07:19:25 CST 2010

Hi all,

the memory increases at each iteration of the following program:

from numpy import ndarray
from scipy.spatial import KDTree

class C(ndarray):

pts = [C((2,)) for i in range(1000)]
for i in xrange(10000):
     tree = KDTree(pts)

It does not occur when using the base class ndarray instead. I've only 
tested on a windows machine. Any idea what happens?

Of course this is a dummy program tailored to emphasis the problem. But 
as I'm using KDTree intensively in my application (both creation and 
query) and I need to fix this memory leak.

Any help is greatly appreciated,

More information about the SciPy-User mailing list