Opened 14 years ago

Closed 14 years ago

#3273 closed defect (fixed)

Memory leak in Geometry.ExportToGML() in C# wrapper

Reported by: joker99 Owned by: tamas
Priority: normal Milestone: 1.7.0
Component: CSharpBindings Version: 1.6.2
Severity: normal Keywords: memory_leak c#
Cc:

Description

There is a memory leak after calling Geometry.ExportToGML() function in c# wrapper when reading shape file. Here is a code snippet to reproduce.

                StringBuilder sb = new StringBuilder();
                // get result set with all features in shape file
                using (var result = _dataSource.ExecuteSQL("select * from shape", null, string.Empty))
                {
                    // read all features
                    while (true)
                    {
                        using (var feature = result.GetNextFeature())
                        {
                            if (feature == null)
                                break;
                            // get feature geometry
                            using (var geometry = feature.GetGeometryRef())
                            {
                                // convert geometry to gml and add to StringBuilder
                                sb.Append(geometry.ExportToGML());
                                // force full GC
                                GC.Collect(2, GCCollectionMode.Forced);
                                GC.WaitForPendingFinalizers();
                            }
                        }
                        
                    }
                    // release result set
                    _dataSource.ReleaseResultSet(result);
                }

If needed I can attach full C# project with test data.

Change History (1)

comment:1 by tamas, 14 years ago

Milestone: 1.7.0
Resolution: fixed
Status: newclosed

Fixed this issue in r18339

Note: See TracTickets for help on using tickets.