Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

is double memory consumption for anonymous data objects necessary?

Former Member
0 Likes
318

Hello,

when using data-references double memory consumption seems to be unavoidable:

In the following example, we take the fm-parameter table_to_display (without any type) and convert it into a dynamically created internal table.

DATA: tab_ref type ref to data.

field-symbols: <g_outtab> type standard table.

CREATE DATA tab_ref TYPE STANDARD TABLE OF (p_structure).

ASSIGN tab_ref->* TO <g_outtab>.

LOOP AT table_to_display ASSIGNING <wa_outtab>.

lv_tabix = sy-tabix.

APPEND <wa_outtab> TO <g_outtab>.

DELETE table_to_display INDEX lv_tabix.

ENDLOOP.

  • ENDIF.

REFRESH table_to_display[].

When starting the program and analysing the memory in the debugger tab_ref and <g_outtab> both allocate (nearly) the same memory.

If we have large lists, we sometimes run out of memory.

Does anybody know, how to release one of the data objects?

Thanks in advance

kind regards

Olaf

1 ACCEPTED SOLUTION
Read only

bryan_cain
Contributor
0 Likes
276

As far as I can tell, the problem isn't because you're using a data reference, it's because you're using two different tables, one to store the data and one to display the data. Presumably in the real world, the display is slightly different from the driver table, because otherwise you should just display the driver and not have a second table (or data reference).

That said, I haven't found a good way to do it - the DELETE doesn't lessen the memory footprint. I believe the FREE statement does - but by the time you could use it, you've already hit the memory limit (ie, outside the loop).

1 REPLY 1
Read only

bryan_cain
Contributor
0 Likes
277

As far as I can tell, the problem isn't because you're using a data reference, it's because you're using two different tables, one to store the data and one to display the data. Presumably in the real world, the display is slightly different from the driver table, because otherwise you should just display the driver and not have a second table (or data reference).

That said, I haven't found a good way to do it - the DELETE doesn't lessen the memory footprint. I believe the FREE statement does - but by the time you could use it, you've already hit the memory limit (ie, outside the loop).