<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<TITLE>Message</TITLE>
<META content="MSHTML 6.00.2800.1226" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial size=2><SPAN
class=348032504-28092003>Frank,</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=348032504-28092003></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=348032504-28092003> I ran across
several memory leaks in ogrfeaturestyle.cpp</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><SPAN class=348032504-28092003><FONT face=Arial size=2>with a large input
file and querying the feature style string I was</FONT></SPAN></DIV>
<DIV><SPAN class=348032504-28092003><FONT face=Arial size=2>getting several
thousand memory leaks.</FONT></SPAN></DIV>
<DIV><SPAN class=348032504-28092003><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=348032504-28092003><FONT face=Arial size=2>The problem was in
two places, first in <FONT
size=2>CreateStyleToolFromStyleString</FONT></FONT></SPAN></DIV>
<DIV><SPAN class=348032504-28092003><FONT face=Arial size=2>it was not calling
CSLDestroy(papszToken);</FONT></SPAN></DIV>
<DIV><SPAN class=348032504-28092003><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=348032504-28092003><FONT face=Arial size=2>Then in the
destructors of <FONT size=2>OGRStyleTool subclasses they
were</FONT></FONT></SPAN></DIV>
<DIV><SPAN class=348032504-28092003><FONT face=Arial size=2>only calling <FONT
size=2>CPLFree(m_pasStyleValue);</FONT></FONT></SPAN></DIV>
<DIV><SPAN class=348032504-28092003><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=348032504-28092003><FONT face=Arial size=2>The problem with
this is m_pasStyleValue is a vector like class of</FONT></SPAN></DIV>
<DIV><SPAN class=348032504-28092003></SPAN><SPAN class=348032504-28092003><FONT
size=2>several OGRStyleValue's. Inside <FONT size=2>OGRStyleValue can be a
pointer to a</FONT></FONT></SPAN></DIV>
<DIV><FONT size=2><SPAN class=348032504-28092003>heap allocated string in
</SPAN><SPAN class=348032504-28092003>pszValue, which was the
leak.</SPAN></FONT></DIV>
<DIV><FONT size=2><SPAN class=348032504-28092003></SPAN></FONT> </DIV>
<DIV><FONT size=2><SPAN class=348032504-28092003><FONT face=Arial>Below are the
changes that fixed these leaks.</FONT></SPAN></FONT></DIV>
<DIV><FONT size=2><SPAN class=348032504-28092003><FONT
face=Arial></FONT></SPAN></FONT> </DIV>
<DIV><FONT size=2><SPAN class=348032504-28092003><FONT
face=Arial>Thanks</FONT></SPAN></FONT></DIV>
<DIV><FONT size=2><SPAN class=348032504-28092003><FONT
face=Arial></FONT></SPAN></FONT> </DIV>
<DIV><FONT size=2><SPAN class=348032504-28092003><FONT face=Arial>Steve
Brooks</FONT></DIV></SPAN></FONT>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>$ diff <SPAN
class=348032504-28092003>clean</SPAN>/gdal/ogr/ogrfeaturestyle.cpp <SPAN
class=348032504-28092003>modified</SPAN>/gdal/ogr/ogrfeaturestyle.cpp<BR>432a433<BR>>
OGRStyleTool *poStyleTool =
NULL;<BR>434,447c435,447<BR>< if
(CSLCount(papszToken) <2)<BR>< return
NULL;<BR><<BR>< if
(EQUAL(papszToken[0],"PEN"))<BR>< return
new OGRStylePen();<BR>< else if
(EQUAL(papszToken[0],"BRUSH"))<BR><
return new OGRStyleBrush();<BR>< else if
(EQUAL(papszToken[0],"SYMBOL"))<BR><
return new OGRStyleSymbol();<BR>< else if
(EQUAL(papszToken[0],"LABEL"))<BR><
return new OGRStyleLabel();<BR><
else<BR>< return
NULL;<BR><<BR>---<BR>> if (CSLCount(papszToken)
>= 2)<BR>>
{<BR>> if
(EQUAL(papszToken[0],"PEN"))<BR>>
poStyleTool = new OGRStylePen();<BR>>
else if
(EQUAL(papszToken[0],"BRUSH"))<BR>>
poStyleTool = new OGRStyleBrush();<BR>>
else if
(EQUAL(papszToken[0],"SYMBOL"))<BR>>
poStyleTool = new OGRStyleSymbol();<BR>>
else if
(EQUAL(papszToken[0],"LABEL"))<BR>>
poStyleTool = new OGRStyleLabel();<BR>>
}<BR>>
CSLDestroy(papszToken);<BR>> return
poStyleTool;<BR>1394a1395,1402<BR>> for (int i = 0; i <
OGRSTPenLast; i++)<BR>>
{<BR>> if (m_pasStyleValue[i].pszValue !=
NULL)<BR>>
{<BR>>
CPLFree(m_pasStyleValue[i].pszValue);<BR>>
m_pasStyleValue[i].pszValue = NULL;<BR>>
}<BR>> }<BR>1414a1423,1430<BR>> for
(int i = 0; i < OGRSTBrushLast; i++)<BR>>
{<BR>> if (m_pasStyleValue[i].pszValue !=
NULL)<BR>>
{<BR>>
CPLFree(m_pasStyleValue[i].pszValue);<BR>>
m_pasStyleValue[i].pszValue = NULL;<BR>>
}<BR>> }<BR>1434a1451,1458<BR>> for
(int i = 0; i < OGRSTSymbolLast; i++)<BR>>
{<BR>> if (m_pasStyleValue[i].pszValue !=
NULL)<BR>>
{<BR>>
CPLFree(m_pasStyleValue[i].pszValue);<BR>>
m_pasStyleValue[i].pszValue = NULL;<BR>>
}<BR>>
}<BR>1455,1456c1479,1490<BR><
CPLFree(m_pasStyleValue);<BR><<BR>---<BR>> if
(m_pasStyleValue != NULL)<BR>>
{<BR>> for (int i = 0; i <
OGRSTLabelLast; i++)<BR>>
{<BR>> if
(m_pasStyleValue[i].pszValue !=
NULL)<BR>>
{<BR>>
CPLFree(m_pasStyleValue[i].pszValue);<BR>>
m_pasStyleValue[i].pszValue =
NULL;<BR>>
}<BR>> }<BR>>
}<BR>> CPLFree(m_pasStyleValue);</FONT></DIV>
<DIV> </DIV></BODY></HTML>