[Gdal-dev] Small memleak: no CPLCleanupTLS for non-pthreads

Frank Warmerdam fwarmerdam at gmail.com
Wed Aug 24 19:58:07 EDT 2005


On 8/24/05, Ben Discoe <ben at vterrain.org> wrote:
> Would it perhaps be better to avoid the messiness and portability issues of
> an atexit-style callback, and simply expose the function to the user?
> 
> It seems reasonable that my application could call CPLCleanupTLS() during
> shutdown, after it is done with GDAL.  Currently, it does this:
>         GDALDestroyDriverManager();
>         OSRCleanup();
>         CPLFinderClean();
>         delete OGRSFDriverRegistrar::GetRegistrar();
> 
> Exposing one more function (CPLCleanupTLS) in order to avoid memleaks would
> be worth it.  But, i would not be surprised if there are threading
> complexities that i am not realizing.

Ben,

I have implemented a general version of CPLCleanupTLS() that
you would need to call in each thread before exiting to ensure
proper TLS cleanup.  I have done a quick test on all three
build types (Win32, pthreads and stubbed).

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