<!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: [UMN_MAPSERVER-DEV] Help: Memory Leaks</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=2>Thank you Frank for looking in to that...&nbsp; I guess the short answer is that I probably wasn't doing anything wrong.&nbsp; When we have some spare cycles Jani or I will chase some of the other leaks down...</FONT></P>

<P><FONT SIZE=2>On a related note:</FONT>
</P>

<P><FONT SIZE=2>I know most people on this list are on Linux, but for finding memory leaks on Windows I have found a really handy free tool that is super easy to use:</FONT></P>

<P><FONT SIZE=2><A HREF="http://www.codeproject.com/tools/visualleakdetector.asp" TARGET="_blank">http://www.codeproject.com/tools/visualleakdetector.asp</A></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, September 13, 2005 5:23 PM</FONT>
<BR><FONT SIZE=2>To: Ned Harding</FONT>
<BR><FONT SIZE=2>Cc: MAPSERVER-DEV@lists.umn.edu</FONT>
<BR><FONT SIZE=2>Subject: Re: [UMN_MAPSERVER-DEV] Help: Memory Leaks</FONT>
</P>

<P><FONT SIZE=2>On 9/13/05, Ned Harding &lt;nharding@extendthereach.com&gt; wrote:</FONT>
<BR><FONT SIZE=2>&gt;&nbsp; </FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; I'm trying to work with MapServer and getting bunches of memory leaks.&nbsp; </FONT>
<BR><FONT SIZE=2>&gt; I presume I am doing something wrong.</FONT>
<BR><FONT SIZE=2>&gt;&nbsp;&nbsp; </FONT>
<BR><FONT SIZE=2>&gt; In particular there are a bunch of leaks I'm getting in msDrawMap: </FONT>
<BR><FONT SIZE=2>&gt;&nbsp;&nbsp; </FONT>
<BR><FONT SIZE=2>&gt;&nbsp;&nbsp;&nbsp; Call Stack: </FONT>
<BR><FONT SIZE=2>&gt;&nbsp;&nbsp;&nbsp;&nbsp; f:\vs70builds\3077\vc\crtbld\crt\src\strdup.c (48):</FONT>
<BR><FONT SIZE=2>&gt; _strdup </FONT>
<BR><FONT SIZE=2>&gt;&nbsp;&nbsp;&nbsp;&nbsp; s:\3rdparty\gis\mapserver\mapoutput.c (464):</FONT>
<BR><FONT SIZE=2>&gt; msAllocOutputFormat </FONT>
<BR><FONT SIZE=2>&gt;&nbsp;&nbsp;&nbsp;&nbsp; s:\3rdparty\gis\mapserver\mapoutput.c (735):</FONT>
<BR><FONT SIZE=2>&gt; msCloneOutputFormat </FONT>
<BR><FONT SIZE=2>&gt;&nbsp;&nbsp;&nbsp;&nbsp; s:\3rdparty\gis\mapserver\mapoutput.c (694):</FONT>
<BR><FONT SIZE=2>&gt; msApplyOutputFormat </FONT>
<BR><FONT SIZE=2>&gt;&nbsp;&nbsp;&nbsp;&nbsp; s:\3rdparty\gis\mapserver\maplegend.c (324):</FONT>
<BR><FONT SIZE=2>&gt; msDrawLegend </FONT>
<BR><FONT SIZE=2>&gt;&nbsp;&nbsp;&nbsp;&nbsp; s:\3rdparty\gis\mapserver\maplegend.c (403):</FONT>
<BR><FONT SIZE=2>&gt; msEmbedLegend </FONT>
<BR><FONT SIZE=2>&gt;&nbsp;&nbsp;&nbsp;&nbsp; s:\3rdparty\gis\mapserver\mapdraw.c (534): msDrawMap</FONT>
</P>
<BR>

<P><FONT SIZE=2>Ned,</FONT>
</P>

<P><FONT SIZE=2>I created a test case with an embedded image (msautotest/misc/legend.map)</FONT>
<BR><FONT SIZE=2>and was able to reproduce your leak.&nbsp; It seems the legend was</FONT>
<BR><FONT SIZE=2>rendered to an imageObj.&nbsp; The gdImage was &quot;stolen&quot; out of this</FONT>
<BR><FONT SIZE=2>and pushed into a pixmap symbol to render but the rest of the</FONT>
<BR><FONT SIZE=2>imageObj was not cleaned up. </FONT>
</P>

<P><FONT SIZE=2>I also fixed the &quot;can't get rid of the last errorObj in USE_THREAD</FONT>
<BR><FONT SIZE=2>mode&quot; problem.&nbsp; As well I fixed a couple of GDAL/OGR related leaks</FONT>
<BR><FONT SIZE=2>though you might not be seeing those. </FONT>
</P>

<P><FONT SIZE=2>The core rendering sequence of mapserver is pretty much leak </FONT>
<BR><FONT SIZE=2>free, but &quot;esoteric&quot; features like legends, less common data </FONT>
<BR><FONT SIZE=2>providers and unusual use modes such might have issues.&nbsp; I</FONT>
<BR><FONT SIZE=2>encourage you to report them when you run into them. </FONT>
</P>

<P><FONT SIZE=2>Best regards,</FONT>
<BR><FONT SIZE=2>-- </FONT>
<BR><FONT SIZE=2>---------------------------------------+--------------------------------------</FONT>
<BR><FONT SIZE=2>I set the clouds in motion - turn up&nbsp;&nbsp; | 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&nbsp;&nbsp;&nbsp; | Geospatial Programmer for Rent</FONT>
</P>

</BODY>
</HTML>