[gdal-dev] C# API Memory Issues
Dave Goughnour
david.goughnour at elantech-inc.com
Thu Oct 30 06:57:04 EDT 2008
Hello
I am trying to write a simple program that imports Tiger data and uses the OGR C# API to export it to various shape files. Importing the Tiger data in C# is not a problem and I basically copied the code from the createdata.cs sample program to export the geometries to multiple shapefiles (I'm parsing the Tiger data into around 20 different shape files). This seems to work fine for small sample sets but when I try to process larger sets I get the infamous 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.' exception. If I look at the exception details the stack trace is:
at OSGeo.OGR.OgrPINVOKE.delete_Feature(HandleRef jarg1)
at OSGeo.OGR.Feature.Dispose()
at OSGeo.OGR.Feature.Finalize()
I've even stripped my code down to simply generate a whole bunch of points at the same location (i.e. pass a hardcoded string to Geometry.CreateFromWKT) and it still throws this exception at somewhat random, but frequent points.
Are there known memory issues with the C# API?
Is there something I am supposed to be doing to cleanup that is not in the createdata.cs example?
Note that if I call GC.SuppressFinalize on all the features I create it seems to work but I am sure this is not the correct solution.
Any Ideas?
Thanks
Dave Goughnour
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20081030/9b3685a3/attachment.html
More information about the gdal-dev
mailing list