[gdal-dev] How to delete GDALDriver objects

Kor de Jong k.dejong at geo.uu.nl
Tue May 27 16:38:15 EDT 2008


Hi Frank,

Thanks for your reply.

Op dinsdag 27 mei 2008, schreef u:
> > My question is: how should I free the individual drivers allocated by
> > the GDal shared library? Is there a function similar to GDALClose, but
> > than for GDALDriver objects?
>
> GDALDestroyDriverManager() should destroy all the drivers registered
> with the manager before destroying the manager and should be the main
> way of cleaning up.
>
> This is what gdalinfo does, and it seems to work quite clean with valgrind.
>
> So perhaps you need to provide more info.

For each GDALDriver, I create a home brewn Driver instance. When a
Driver instance wants to do raster I/O using its GDALDriver, it calls
GDALDriverManager::DeregisterDriver on the global manager for each
registered GDALDriver, folowed by a call to
GDALDriverManager::RegisterDriver for the wrapped GDALDriver.
So, the driver manager does not contain all GDALDrivers loaded, but
only the one(s) currently used. Given your comments, this means that
when GDALDestroyDriverManager() is called, only the GDALDrivers
registered will be destroyed. The other ones will be left dangling.

In general the question than becomes, how would one free the memory
taken by a GDALDriver which has been deregistered with the
GDALDriverManager.

Thanks,
Kor




More information about the gdal-dev mailing list