Skip to content

Commit 1190408

Browse files
Merge pull request #123 from sebastianrowan/fix_spatialwriter_memory_leak
Fix spatialResultsWriter memory leak issue
2 parents 366b2a4 + 28357f3 commit 1190408

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

resultswriters/spatialwriter.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@ func (srw *spatialResultsWriter) Write(r consequences.Result) {
9393
//if header has been built, add the feature, and the attributes.
9494

9595
feature := layerDef.Create()
96-
//defer feature.Destroy()
96+
defer feature.Destroy() // Destroy feature. I believe this also destroys the geometry object g, defined below. If feature is not destroyed, memory is not released
9797
feature.SetFieldInteger(0, srw.index)
9898
//create a point geometry - not sure the best way to do that.
9999
x := 0.0
100100
y := 0.0
101101
g := gdal.Create(gdal.GeometryType(gdal.GT_Point))
102-
defer g.Destroy()
102+
// defer g.Destroy() // Don't Destroy g (I believe this is handled in feature.Destroy())
103103
for i, val := range r.Headers {
104104
if val == "x" {
105105
x = result[i].(float64)
@@ -182,7 +182,6 @@ func (srw *spatialResultsWriter) Write(r consequences.Result) {
182182
}
183183

184184
srw.index++ //incriment.
185-
//feature.Destroy() //testing an explicit call.//causes seg fault error, probably not calling causes a memory leak... oy vey.
186185
}
187186
func (srw *spatialResultsWriter) Close() {
188187
//not sure what this should do - Destroy should close resource connections.

0 commit comments

Comments
 (0)