[Gdal-dev] GDAL 1.2.1 Released

Frank Warmerdam warmerdam at pobox.com
Thu Jun 24 10:45:06 EDT 2004

Mladen Turk wrote:
> Hi,
>>-----Original Message-----
>>From: gdal-dev-bounces at remotesensing.org [mailto:gdal-dev-
>>Please let me know if you run into any showstopper problems with this
>>and I will reissue it.
> There is a problem with GDAL in general when used as DLL, missing delete
> mechanism for objects that are internally allocated using operator new.
> Right now there is no way (at least I'm not aware of any) to release those
> objects. 
> For example the OGRLayer, OGRStyleLabel etc... cannot be deleted withing
> GDAL/OGR heap.
> Either something like OGR_G_DestroyGeometry or OGR_F_DestroyFeature should
> be used or something like I proposed in MS #697.
> http://mapserver.gis.umn.edu/bugs/show_bug.cgi?id=697


As I understand it this is an issue if you use GDAL as a DLL, but build
with static LIBC.  That means each DLL and the main program all have a
seperate heap, and it is critical that delete be called from within
the same DLL as the allocation took place within.

It can be avoided by building GDAL and the application with a runtime
C library.  I think this is accomplished with the /MD switch.

The other approach is to provide some sort of external destructor access
via exact function entry points.  I have done this already for many GDAL and
OGR objects.  In particular for GDAL it is usually sufficient to call GDALClose()
on a dataset handle to clean things up.

In OGR there are more objects to worry about. Features, datasources, and
coordinate system objects.  I think I have specific destructors for each of
those.  If others I needed I can extend it.  I am not keen to add a generic
OGRDelete as you have suggested in your bug report. I prefer specific
destructors.  But certainly MapServer needs to be updated to use them.  In
fact, I would like to also rewrite the MapServer mapogr.cpp code to use the
OGR C API instead of the C++ API.  This would address the delete issues and
other C++ linkage fragility issues all in one pass.  Hopefully this can be
done in time for the MapServer 4.4 release.

I will add this note to the mapserver bugzilla report as well for completeness.

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    | Geospatial Programmer for Rent

More information about the Gdal-dev mailing list