[FWTools] OGRFeature memory problem?

Mike Toothaker mtoothaker at milcord.com
Mon May 15 10:22:45 EDT 2006

> -----Original Message-----
> From: Frank Warmerdam [mailto:fwarmerdam at gmail.com] On Behalf Of Frank
> Warmerdam
> Sent: Monday, May 15, 2006 9:47 AM
> To: Mike Toothaker
> Cc: fwtools at lists.maptools.org
> Subject: Re: [FWTools] OGRFeature memory problem?
> Mike Toothaker wrote:
> > Hello,
> >
> >
> >
> > I will start off by apologizing for my lack of geospatial knowledge.  I
> > have just started a project and I am trying
> >
> > to get caught up on the geospatial stuff as quickly as I can while
> > working with it.  We are using gdal in our project
> >
> > and I have the following code(almost an exact copy paste from the gdal
> > website).
> ...
> >         delete poFeature;           //ß--- Error here
> Mike,
> Due to what I consider a brain-dead approach to DLLs it is common for
> microsoft applications to have distinct heaps for different DLLs.  This
> means that you can't delete an object allocated in a different DLL unless
> you take great care to ensure you are using the same heap.  I normally
> build
> everything with /MD so all modules use the same MSVCRT.DLL for memory
> allocation (hence one heap).
> However, that is not always possible.  To be on the safe side you should
> instead delete your features using:
>   OGRFeature::DestroyFeature( poFeature );
> Should you find yourself needing to dynamically create  feature I would
> suggest using:
>   poFeature = OGRFeature::CreateFeature( poFeatureDefn );
> Some other classes and factories have similar static
> constructor/descructor
> methods that should be used in preference to direct use of new and delete.
> I *hate* this issue.
> If you let me know exactly where what web page on the web site you worked
> from, I'll change it to use OGRFeature::DestroyFeature().
> PS. This sort of GDAL specific development issue might be better posed on
> gdal-dev.  I generally think of the FWTools list as a place for FWTools
> specific packaging issues, and high level user questions.
> Best regards,
> --
> ---------------------------------------+----------------------------------
> ----
> I set the clouds in motion - turn up   | Frank Warmerdam,
> warmerdam at pobox.com
> light and sound - activate the windows | http://pobox.com/~warmerdam
> and watch the world go round - Rush    | President OSGF, http://osgeo.org


 I am still getting the same problem even using the
OGRFeature::CreateFeature and OGRFeature::DestroyFeature.  Maybe it is
something new that has been introduced in VC++ 2005(although now that I have
typed that, I remember that we have the same problem with the product being
built on VS2003).  

The webpage I worked off of is: http://www.gdal.org/ogr/ogr_apitut.html in
the "Writing to OGR" section.  

I will also look into posting the problem to the gdal-dev mailing list.  If
I understand correctly I am also building with the /MD(in the project
properties it says "Multithreaded DLL"?) and no luck there either.  :-( 



More information about the FWTools mailing list