<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Memory leak in get_Geometry? [C++] in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/memory-leak-in-get-geometry-c/m-p/53924#M1438</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hey all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm having some troubles in SDK 10.1 with the following code snippet:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
IGeometryCollectionPtr geom_coll (line);&amp;nbsp; // line is an IPolyline
long count;
if (FAILED(geom_coll-&amp;gt;get_GeometryCount(&amp;amp;count)))
&amp;nbsp;&amp;nbsp;&amp;nbsp; return false;

for (int i (0); i &amp;lt; count; ++i)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; IGeometryPtr geom;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (FAILED(geom_coll-&amp;gt;get_Geometry(i, &amp;amp;geom)))&amp;nbsp;&amp;nbsp;&amp;nbsp; // &amp;lt;-----
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The call to get_Geometry keeps some memory allocated that I can't seem to reclaim, and it quickly adds up for large data sets. DevPartner's BoundsChecker marks it as a memory leak, four calls deep into Geometry.dll. The problem can be reproduced even if the for-loop is otherwise empty.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any idea what I'm doing wrong here? Or perhaps there is another way to get the line's geometry?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 01 Aug 2013 08:34:38 GMT</pubDate>
    <dc:creator>DuncanMallace</dc:creator>
    <dc:date>2013-08-01T08:34:38Z</dc:date>
    <item>
      <title>Memory leak in get_Geometry? [C++]</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/memory-leak-in-get-geometry-c/m-p/53924#M1438</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hey all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm having some troubles in SDK 10.1 with the following code snippet:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
IGeometryCollectionPtr geom_coll (line);&amp;nbsp; // line is an IPolyline
long count;
if (FAILED(geom_coll-&amp;gt;get_GeometryCount(&amp;amp;count)))
&amp;nbsp;&amp;nbsp;&amp;nbsp; return false;

for (int i (0); i &amp;lt; count; ++i)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; IGeometryPtr geom;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (FAILED(geom_coll-&amp;gt;get_Geometry(i, &amp;amp;geom)))&amp;nbsp;&amp;nbsp;&amp;nbsp; // &amp;lt;-----
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The call to get_Geometry keeps some memory allocated that I can't seem to reclaim, and it quickly adds up for large data sets. DevPartner's BoundsChecker marks it as a memory leak, four calls deep into Geometry.dll. The problem can be reproduced even if the for-loop is otherwise empty.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any idea what I'm doing wrong here? Or perhaps there is another way to get the line's geometry?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Aug 2013 08:34:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/memory-leak-in-get-geometry-c/m-p/53924#M1438</guid>
      <dc:creator>DuncanMallace</dc:creator>
      <dc:date>2013-08-01T08:34:38Z</dc:date>
    </item>
  </channel>
</rss>

