#5623 closed defect (fixed)
CSV driver: memory leak when geometries are supplied but not used
Reported by: | cdestigter | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | 1.11.1 |
Component: | OGR_SF | Version: | 1.11.0 |
Severity: | normal | Keywords: | csv SetGeometryDirectly failure |
Cc: | Robert Coup |
Description
- create a CSV datasource
- create a bunch of features with geometries set using
SetGeometryDirectly
- use the default creation options (ie discard geometries in CSV output)
The process will leak memory like a sieve.
Using SetGeometry
, or using GEOMETRY=AS_WKT
or GEOMETRY=AS_XY
avoids the problem.
The following code reproduces the memory leak:
#!/usr/bin/python # Try with `valgrind --leak-check=full /usr/bin/python ./memleak.py` from osgeo import ogr ogrdriver = ogr.GetDriverByName("CSV") ds = ogrdriver.CreateDataSource("memleak.csv") l = ds.CreateLayer("memleak", options=['GEOMETRY=AS_WKT']) l_defn = l.GetLayerDefn() field_def = ogr.FieldDefn("field1", ogr.OFTString) field_def.SetWidth(100) assert not l.CreateField(field_def) for i in xrange(5000): if i % 500 == 0: print i f = ogr.Feature(l_defn) g = ogr.CreateGeometryFromWkt('POINT(%.3f %.3f)' % (i, i)) f.SetGeometryDirectly(g) f.SetField("field1", str(i)) l.CreateFeature(f) del f del l, ds
Our gdal is built from https://github.com/koordinates/gdal/tree/trunk-kx
Change History (6)
comment:1 by , 10 years ago
Cc: | added |
---|
comment:2 by , 10 years ago
comment:4 by , 10 years ago
I should also mention I tried ESRI Shapefile and GPKG drivers, and neither exhibited this memory leak.
comment:5 by , 10 years ago
Keywords: | SetGeometryDirectly failure added |
---|---|
Milestone: | → 1.11.1 |
Resolution: | → fixed |
Status: | new → closed |
Version: | svn-trunk → 1.11.0 |
trunk r27592, branches/1.11 r27593: "Fix OGRFeature::SetGeometryDirectly() and SetGeomFieldDirectly() to free the passed geometry even if the method fails (#5623)"
Note:
See TracTickets
for help on using tickets.
if you comment out
options=['GEOMETRY=AS_WKT']
obviously...