<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=US-ASCII">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2658.24">
<TITLE>RE: [Gdal-dev] Memory Leaks</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=2>Thanks Frank... </FONT>
</P>
<P><FONT SIZE=2>Is there any harm in calling CPLCleanupTLS in a thread and then using that thread again? Will it make new structures? If so, that will make it easy for me to reference count.</FONT></P>
<P><FONT SIZE=2>Otherwise, is there any harm in calling it if it has never been initialized?</FONT>
</P>
<P><FONT SIZE=2>And finally, has anything been done in OGR post 1.3 that would be risky for production code?</FONT>
</P>
<P><FONT SIZE=2>Thanks again,</FONT>
</P>
<P><FONT SIZE=2>Ned.</FONT>
</P>
<P><FONT SIZE=2>-----Original Message-----</FONT>
<BR><FONT SIZE=2>From: Frank Warmerdam [<A HREF="mailto:fwarmerdam@gmail.com">mailto:fwarmerdam@gmail.com</A>] </FONT>
<BR><FONT SIZE=2>Sent: Tuesday, August 30, 2005 8:58 AM</FONT>
<BR><FONT SIZE=2>To: Ned Harding</FONT>
<BR><FONT SIZE=2>Cc: Gdal-dev@lists.maptools.org</FONT>
<BR><FONT SIZE=2>Subject: Re: [Gdal-dev] Memory Leaks</FONT>
</P>
<P><FONT SIZE=2>On 8/30/05, Ned Harding <nharding@extendthereach.com> wrote:</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> I am trying to clear out all my memory leaks in a project I have. I </FONT>
<BR><FONT SIZE=2>> have 2 memory leaks in OGR that I can't figure out. These are minor, </FONT>
<BR><FONT SIZE=2>> but I'd still rather not have any leaks since this code can be used </FONT>
<BR><FONT SIZE=2>> for a server process that is expected to live for a long time.</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> 2 functions allocate memory that never get free'd again. </FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> CPLGetErrorContext</FONT>
<BR><FONT SIZE=2>> CPLGetTLSList</FONT>
</P>
<P><FONT SIZE=2>Ned, </FONT>
</P>
<P><FONT SIZE=2>I would *love* to be able to clear these up properly, but I am not sure about how to register "atexit" handers for threads in a cross platform way. In the meantime, you can call CPLCleanupTLS() at the point where the threads are exiting. </FONT></P>
<P><FONT SIZE=2>Note that CPLCleanupTLS() was added after the 1.3.0 release, so you would need to be using GDAL CVS to get it. </FONT>
</P>
<P><FONT SIZE=2>Best regards,</FONT>
<BR><FONT SIZE=2>-- </FONT>
<BR><FONT SIZE=2>---------------------------------------+--------------------------------</FONT>
<BR><FONT SIZE=2>---------------------------------------+------</FONT>
<BR><FONT SIZE=2>I set the clouds in motion - turn up | Frank Warmerdam, warmerdam@pobox.com</FONT>
<BR><FONT SIZE=2>light and sound - activate the windows | <A HREF="http://pobox.com/~warmerdam" TARGET="_blank">http://pobox.com/~warmerdam</A></FONT>
<BR><FONT SIZE=2>and watch the world go round - Rush | Geospatial Programmer for Rent</FONT>
</P>
</BODY>
</HTML>