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

Frank Warmerdam fwarmerdam at gmail.com
Mon Aug 22 09:06:55 EDT 2005


On 8/22/05, Ben Discoe <ben at vterrain.org> wrote:
> I am looking at some small new memleaks that have appeared in moving to
> 1.3.0.  There are some allocations in CPLGetTLSList() which are only freed
> in the function CPLCleanupTLS().  However, of the 3 new threading options,
> CPLCleanupTLS() only exists in the case of CPL_MULTIPROC_PTHREAD.
> 
> 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?

Ben,

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. 

If you can come up with a not-too-complicated approach to cleaning this
up, I would be interested.  Essentially some sort of thead "atexit" function.
But we would need to ensure it doesn't get called till fairly late in thread
teardown as we don't want to destroy the TLS structures till other 
GDAL/OGR/CPL level activity for the thread is all complete. 

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