Memory Management and Large Internal Tables
Understand how internal tables consume memory and how to design high-volume processing safely.
Explanation
Internal tables are stored in application server memory. Large tables with many columns and rows can increase memory consumption and may cause runtime or timeout issues. Developers should select only required fields, clear temporary tables when no longer needed and avoid holding unnecessary duplicate datasets. CLEAR removes content but may keep allocated memory for reuse, while FREE releases memory more explicitly. For very large processing, consider PACKAGE SIZE, streaming-style processing or database pushdown using Open SQL/CDS where suitable. Good ABAP design balances database load, application memory and maintainability.
Code example
SELECT bukrs, belnr, gjahr, hkont, wrbtr FROM bseg INTO TABLE @DATA(lt_items) WHERE bukrs = @p_bukrs AND gjahr = @p_gjahr. * After final output is prepared and temporary data is no longer neededFREE lt_items.Real project scenario
A reconciliation report loads millions of line items into memory and then filters them. A better design is to select only required fields, filter earlier, process in packages and avoid keeping multiple full copies of the same data.
Common mistakes
- Selecting all fields when only a few are needed. - Keeping multiple copies of large internal tables. - Not freeing temporary tables in long-running programs. - Processing millions of rows fully in application memory without design review.
Best practices
- Select only required fields. - Avoid unnecessary duplicate internal tables. - Use FREE for large temporary tables when done. - Consider database pushdown for large aggregation or filtering.
Interview angle
Architect-level candidates should talk about memory, package processing, pushdown and measurable performance.