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

Ben Discoe ben at vterrain.org
Wed Aug 24 02:59:24 EDT 2005


> > On Windows, it defaults to CPL_MULTIPROC_WIN32, so there is no
> > CPLCleanupTLS() code.  Should it be added, or is there any 
> > other way to release this memory?

Frank wrote:
> Pthreads has a mechanism to register a callback function for 
> cleanup with a TLS object but I am not aware of a 
> corresponding mechanism for the win32 api.

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




More information about the Gdal-dev mailing list