Opened 14 years ago

Closed 14 years ago

Last modified 12 years ago

#12101 closed (fixed)

django.contrib.gis.gdal.OGRGeometry leaking memory

Reported by: nino@… Owned by: jbronn
Component: GIS Version: 1.1
Severity: Keywords: GDAL, memory, leak
Cc: techlog@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

gdal.OGRGeometry from WKB and WKT leaks memory like crazy (using GDAL 1.6.0, on debian). Reference counts do not appear to go up, but memory climbs rapidly.

From WKB:

from django.contrib.gis.geos import Point
from django.contrib.gis import gdal

geom = Point(1,1)
geom.srid = 4326
for i in xrange(1000000):
   g = gdal.OGRGeometry(geom.wkb, geom.srid)
   del g

From WKT:

from django.contrib.gis.geos import Point
from django.contrib.gis import gdal

geom = Point(1,1)
geom.srid = 4326
for i in xrange(1000000):
   g = gdal.OGRGeometry(geom.wkt, geom.srid)
   del g

Attachments (1)

gdal_leak_fix.diff (633 bytes ) - added by jbronn 14 years ago.
Fixes memory leak when assigning SpatialReference to OGRGeometry

Download all attachments as: .zip

Change History (5)

comment:1 by jbronn, 14 years ago

milestone: 1.2
Owner: changed from nobody to jbronn
Status: newassigned

I've confirmed this is as a bug, the leak is real. I think it's within the SpatialReference code because there's no balloon in memory usage when I change to this:

for i in xrange(1000000):
   g = gdal.OGRGeometry(geom.wkt)
   del g

by jbronn, 14 years ago

Attachment: gdal_leak_fix.diff added

Fixes memory leak when assigning SpatialReference to OGRGeometry

comment:2 by jbronn, 14 years ago

I've come up with a patch that works, and all tests pass with it. However I can't fully explain yet why it works over the previous version, other than that somehow the cloned SpatialReference object references (within OGR, not Python) were not being released. As soon as I can explain why those references were not being released, I'll commit the patch.

comment:3 by jbronn, 14 years ago

Resolution: fixed
Status: assignedclosed

(In [11708]) [1.1.X] Fixed #12101 -- OGRGeometry does not need to create a clone of the SpatialReference object upon assignment.

Backport of r11707 from trunk.

comment:4 by Jacob, 12 years ago

milestone: 1.2

Milestone 1.2 deleted

Note: See TracTickets for help on using tickets.
Back to Top