Ticket #181 (closed defect: fixed)

Opened 14 months ago

Last modified 10 months ago

Memory leak

Reported by: seang Owned by: seang
Priority: major Milestone:
Component: Rtree Version:
Keywords: memory Cc:

Description

I fixed the problem, it deem seem to be a memory leak

in rtree/wrapper.cc, in the PyListVisitor? class, I changed the visitData function to the following:

void visitData(const IData & d) {

PyObject? * ob = PyLong?_FromLongLong(d.getIdentifier()); PyList?_Append(ids, ob); Py_DECREF(ob);

}

after rebuilding this, I ran the test described in the previous post, and the memory leak was fixed. I then tested my own application as a correctness test, and although the running time increased slightly, the output was correct.

- Chris

From: lithium_eadgbe@… To: community@… Date: Sat, 3 Jan 2009 16:51:19 -0400 Subject: [Community] Possible Rtree 0.4.1 memory leak, Does spatialindex do query caching?

Running the following python script, which uses Rtree 0.4.1, which uses spatialindex, after the index is built the repeated queries cause the memory usage to increase by megabytes a second. This is not a python garbage collection problem, you can see, the ref count of zxy, and x (results) are both equal (2), which indicates one reference for the variable, and one reference for the parameter to the getrefcount function.

from rtree import Rtree import sys def y(index):

zxy = [ 1, 2, 3, 4 ] print "zyx: %d"%(sys.getrefcount(zxy)) x = index.intersection((0.25, 0.25, 0.75, 0.75)) print "x: %d"%(sys.getrefcount(x)) print "x: %d"%(sys.getrefcount(x)) del x[:] del x

index = Rtree() for i in range(0, 50000):

index.add(i, (0, 0, 1, 1))

while 1:

y(index)

Thanks,

- Chris

Change History

Changed 10 months ago by hobu

  • status changed from new to closed
  • resolution set to fixed

Fixed in r1281.

Note: See TracTickets for help on using tickets.