2023 Dec 01 8:17 AM
Hello
We are managing our data into a loop by creating some objects.
In order to improve the performance of the report, will a CLEAR statement improve the performance of the memory management and the performance of the report?
AS IS
loop at lt assigning (<lfs>)
data(lr1) = cast cl_...(<lfs>).
data(lr2) = lr1.->get_TOTO()
....
....
endloop
TO BE
loop
data(lr1) = cast cl_...(<lfs>).
data(lr2) = lr1.->get_TOTO()
...
...
CLEAR: lr1, lr2...
endloop
Please imagine the instantiation of 10 objects during each loop.
Will the performance be improved?
2023 Dec 01 8:40 AM
That's a weird question. Why do you think a CLEAR would help improve the performance? SAP never does that (in mainstream software at least).
2023 Dec 01 8:54 AM
Hello
I am thinking about memory and garbage collector management.
BR
2023 Dec 01 2:24 PM
Hi,
Efficient memory management is essential for optimal performance.
I would try to utilize LOOP AT <itab> REFERENCE INTO <ref_obj> syntax, if it really works for specific scenario. This would avoid your Field symbol assignment and later type casting to another object reference. However, considering lesser visibility on what complete loop does, you can always make your own decisions on how to proceed.
Thanks.
2023 Dec 01 4:19 PM
Please use the COMMENT button for comments, asking for complements, adding details, replying to a comment or a proposed solution or to the OP question, etc., ANSWER is only to propose a solution, dixit SAP text at the right of the answer area.
2023 Dec 02 6:45 PM
I was worried about abap instantiation management in a user session and the garbage collector,
I was worried if some issues could happen with too many instantiations and I was thinking if a systematic clear of useless instantiation could help in enduser session memory management.
Many thanks for your answers.
2023 Dec 01 4:23 PM
Based on your input, CLEAR is useless.
If your question is about garbage collection, how often it runs and so on, you may look at the ABAP documentation. It should be generally sufficient. If you experience a high memory consumption because the garbage collection doesn't run at the right time, you may invoke the garbage collection explicitly.