<?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 Re: Memory leak using (nested) internal table with reference to data in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/memory-leak-using-nested-internal-table-with-reference-to-data/m-p/8241651#M1630198</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi  Matt  ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Only Deleting  a data   will not deallocate  memory  . you need to Free  that internal table   . &lt;/P&gt;&lt;P&gt;but as it contains  single record after  after deleting  . The memory will remain as it is  .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;Deepak.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 24 Sep 2011 05:52:23 GMT</pubDate>
    <dc:creator>deepak_dhamat</dc:creator>
    <dc:date>2011-09-24T05:52:23Z</dc:date>
    <item>
      <title>Memory leak using (nested) internal table with reference to data</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/memory-leak-using-nested-internal-table-with-reference-to-data/m-p/8241646#M1630193</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've an internal table GT_BUFFER with the following structure. &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;pernr           TYPE pernr_d,
infty           TYPE infty,
r_infty_table   TYPE REF TO data&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It's a HASHED table with unique key pernr infty. I use this code to add records to the buffer (if the record isn't already there)&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;FIELD-SYMBOLS:&amp;lt;t_prelp&amp;gt;      TYPE prelp_tab.
...
    CREATE DATA ls_buffer-r_infty_table TYPE prelp_tab.
    ls_buffer-pernr = i_pernr. " The current pernr
    ls_buffer-infty = i_infty. " The current infotype
    ASSIGN ls_buffer-r_infty_table-&amp;gt;* TO &amp;lt;t_prelp&amp;gt;.
    INSERT ls_buffer INTO TABLE gt_buffer.
...
  &amp;lt;t_prelp&amp;gt; ) = it_prelp. " My supplied internal table with data of type prelp_tab.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem is, that according to the memory analyser, each time I insert a record into the buffer, and additional *2MB" of memory is allocated to GT_BUFFER. Even though the record typically has only 1 record in its nested table. (Used memory is about 4K!). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The OS in Linux. I'm wondering if this is a bug in the kernel, or if there is some other explanation. The programming &lt;EM&gt;looks&lt;/EM&gt; sound to me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;matt&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Sep 2011 11:01:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/memory-leak-using-nested-internal-table-with-reference-to-data/m-p/8241646#M1630193</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2011-09-23T11:01:11Z</dc:date>
    </item>
    <item>
      <title>Re: Memory leak using (nested) internal table with reference to data</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/memory-leak-using-nested-internal-table-with-reference-to-data/m-p/8241647#M1630194</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi  Matt,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The internal tables, just like the database tables, are organized&lt;/P&gt;&lt;P&gt;in blocks or pages.  Only when entries are&lt;/P&gt;&lt;P&gt;written to the table the system create a table header and a table body. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it allocates  momory according   to pages   , size of  allocations  is generally  8kb   when  the records  are actually inserted   .&lt;/P&gt;&lt;P&gt; accordingly it allocates   memory  to internal table  dynamically  .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am sure you might be aware of this  .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Deepak.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Sep 2011 11:54:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/memory-leak-using-nested-internal-table-with-reference-to-data/m-p/8241647#M1630194</guid>
      <dc:creator>deepak_dhamat</dc:creator>
      <dc:date>2011-09-23T11:54:05Z</dc:date>
    </item>
    <item>
      <title>Re: Memory leak using (nested) internal table with reference to data</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/memory-leak-using-nested-internal-table-with-reference-to-data/m-p/8241648#M1630195</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No one uses internal tables with headers any more &lt;SPAN __jive_emoticon_name="alert"&gt;&lt;/SPAN&gt;, so the 8k doesn't matter. But you're not far off the truth. Yes, the problem lies with the allocation of memory in the nested table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is where the abap you didn't see becomes relevant... turns out it's vital. The key lies in how &amp;lt;t_prelp&amp;gt; gets populated. There is another internal table lt_prelp (same structure), which contains ~700 records. It has allocated and used 2MB. I copy lt_prelp to &amp;lt;t_prelp&amp;gt;, and then use a DELETE &amp;lt;t_prelp&amp;gt; WHERE pernr = i_pernr. This gets rid of all records in &amp;lt;t_prelp&amp;gt;, except for one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;t_prelp&amp;gt; has now only 8K used - but retains the 2MB allocated. When that gets put into GT_BUFFER, that 2MB is irretrievably allocated. So, after 600 records, I'm at 1.2GB and run out of memory.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Some kind of CONDENSE itab, would be nice. Force a deallocation of unused memory. I've implemented a different workaround.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;matt&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Matt on Sep 23, 2011 2:28 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Sep 2011 12:18:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/memory-leak-using-nested-internal-table-with-reference-to-data/m-p/8241648#M1630195</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2011-09-23T12:18:27Z</dc:date>
    </item>
    <item>
      <title>Re: Memory leak using (nested) internal table with reference to data</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/memory-leak-using-nested-internal-table-with-reference-to-data/m-p/8241649#M1630196</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Matt,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When we copy the data from one internal table to another internal table using [] or direct assign, system don't copy it right away. It just keeps pointer to what data is changing. At end of processing it determines what to adjust. Thus, it allocates the same memory as what source table has.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The key lies in how &amp;lt;t_prelp&amp;gt; gets populated. There is another internal table lt_prelp (same structure), which contains ~700 records. It has allocated and used 2MB. I copy lt_prelp to &amp;lt;t_prelp&amp;gt;, and then use a DELETE &amp;lt;t_prelp&amp;gt; WHERE pernr = i_pernr. This gets rid of all records in &amp;lt;t_prelp&amp;gt;, except for one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I had a similar problem in past due to Internal table copy, it was not for Memory leak though. It was for performance. We had about 25K lines in itab. It was copying all of them in the seperate table in a LOOP. so, eventually it was taking about 65% time in only APPEND statement. You can read more that [Performance of ITAB Copy|http://help-abap.zevolving.com/2011/06/performance-of-itab-copy/]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naimesh Patel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Sep 2011 12:30:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/memory-leak-using-nested-internal-table-with-reference-to-data/m-p/8241649#M1630196</guid>
      <dc:creator>naimesh_patel</dc:creator>
      <dc:date>2011-09-23T12:30:21Z</dc:date>
    </item>
    <item>
      <title>Re: Memory leak using (nested) internal table with reference to data</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/memory-leak-using-nested-internal-table-with-reference-to-data/m-p/8241650#M1630197</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Matt,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;I've implemented a different workaround.&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;May be you could share the details of the workaround &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Suhas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Sep 2011 12:46:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/memory-leak-using-nested-internal-table-with-reference-to-data/m-p/8241650#M1630197</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2011-09-23T12:46:30Z</dc:date>
    </item>
    <item>
      <title>Re: Memory leak using (nested) internal table with reference to data</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/memory-leak-using-nested-internal-table-with-reference-to-data/m-p/8241651#M1630198</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi  Matt  ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Only Deleting  a data   will not deallocate  memory  . you need to Free  that internal table   . &lt;/P&gt;&lt;P&gt;but as it contains  single record after  after deleting  . The memory will remain as it is  .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;Deepak.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 24 Sep 2011 05:52:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/memory-leak-using-nested-internal-table-with-reference-to-data/m-p/8241651#M1630198</guid>
      <dc:creator>deepak_dhamat</dc:creator>
      <dc:date>2011-09-24T05:52:23Z</dc:date>
    </item>
    <item>
      <title>Re: Memory leak using (nested) internal table with reference to data</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/memory-leak-using-nested-internal-table-with-reference-to-data/m-p/8241652#M1630199</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hello Matt,&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I've implemented a different workaround.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; May be you could share the details of the workaround &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; BR,&lt;/P&gt;&lt;P&gt;&amp;gt; Suhas&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Oh alright... I just thought the workaround was kind of obvious!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead of copying the itab and deleting the records I don't want in the copy, I insert into the copy only the records I want. Simples.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;@Deepak - , Free, Clear and Refresh all allow the memory to be deallocated - at least in later ABAP versions. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;matt&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 24 Sep 2011 11:04:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/memory-leak-using-nested-internal-table-with-reference-to-data/m-p/8241652#M1630199</guid>
      <dc:creator>matt</dc:creator>
      <dc:date>2011-09-24T11:04:05Z</dc:date>
    </item>
  </channel>
</rss>

