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

<P><FONT SIZE=2>I'm trying to work with MapServer and getting bunches of memory leaks.&nbsp; I presume I am doing something wrong.</FONT>
<BR><FONT SIZE=2>&nbsp;</FONT>
<BR><FONT SIZE=2>In particular there are a bunch of leaks I'm getting in msDrawMap:</FONT>
<BR><FONT SIZE=2>&nbsp;</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp; Call Stack:</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; f:\vs70builds\3077\vc\crtbld\crt\src\strdup.c (48): _strdup</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; s:\3rdparty\gis\mapserver\mapoutput.c (464): msAllocOutputFormat</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; s:\3rdparty\gis\mapserver\mapoutput.c (735): msCloneOutputFormat</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; s:\3rdparty\gis\mapserver\mapoutput.c (694): msApplyOutputFormat</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; s:\3rdparty\gis\mapserver\maplegend.c (324): msDrawLegend</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; s:\3rdparty\gis\mapserver\maplegend.c (403): msEmbedLegend</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; s:\3rdparty\gis\mapserver\mapdraw.c (534): msDrawMap</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; s:\wrigley\plugins\wrigleyspatialpluginsengine\mapserver.cpp (423): SRC::Wrigley::MapServerInterface::MakeMap</FONT>
</P>

<P><FONT SIZE=2>The code calling msDrawMap looks like:</FONT>
</P>

<P>&nbsp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nbsp;&nbsp;&nbsp; <FONT SIZE=2>msFreeImage(pImage);</FONT>
</P>

<P><FONT SIZE=2>Also, I'm getting leaks from msCleanup()!</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; s:\3rdparty\gis\mapserver\maperror.c (172): msGetErrorObj</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; s:\3rdparty\gis\mapserver\maperror.c (256): msResetErrorList</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; s:\3rdparty\gis\mapserver\maputil.c (1307): msCleanup</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; s:\wrigley\plugins\wrigleyspatialpluginsengine\mapserver.cpp (443): SRC::Wrigley::MapServerInterface::MakeMap</FONT>
</P>

<P><FONT SIZE=2>It seams that msCleanup creates an error object even if there wasn't previously one and it doesn't clean it up.</FONT>
</P>

<P><FONT SIZE=2>What am I doing wrong?&nbsp; There about about 50 more leaks than this and this is pruducing a single map.&nbsp; I'm calling msFreeMap and msCleanup... Is there something different I should be calling?</FONT></P>

<P><FONT SIZE=2>&nbsp;</FONT>
<BR><FONT SIZE=2>Ned Harding</FONT>
<BR><FONT SIZE=2>Chief Technology Officer</FONT>
<BR><FONT SIZE=2>SRC - Extending the Reach of Micromarketing</FONT>
<BR><FONT SIZE=2>3825 Iris Ave Suite 150</FONT>
<BR><FONT SIZE=2>Boulder, CO 80303</FONT>
<BR><FONT SIZE=2>(303) 440-8896 x104</FONT>
</P>

<P><FONT SIZE=2><A HREF="http://www.extendthereach.com" TARGET="_blank">http://www.extendthereach.com</A> &lt;<A HREF="http://www.extendthereach.com/" TARGET="_blank">http://www.extendthereach.com/</A>&gt; </FONT>
</P>

<P><FONT SIZE=2>Technology in Action:</FONT>
</P>

<P><FONT SIZE=2><A HREF="http://www.DemographicsNow.com" TARGET="_blank">http://www.DemographicsNow.com</A> &lt;<A HREF="http://www.demographicsnow.com/" TARGET="_blank">http://www.demographicsnow.com/</A>&gt; </FONT>
</P>

</BODY>
</HTML>