2022 Mar 25 11:44 AM
Hi all,
I am using own BADI's to handle different implementations based on several filter criteria.
The BADI's are used inside RFC function modules.
The external sytem is calling the RFC's within a session and is keeping the session open as long as necessary. This means it could be that within one session 2 times the same RFC is called.
Now I want to optimize the memory usage of this open session and furthermore avoid that first RFC call is maybe influencing anyhow the second call. I.e. if I have class attributes at BADI implementation which were changed.
Is ther something like a free object or any way to destroy a BADI instance after using it and before leaving the RFC function?
Regards
Christian
2022 Mar 25 12:08 PM
In ABAP there is no standard way to clean memory from instance. When people will propose you Free or something else, this will only remove the link between the variable & the instance, but the instance stay in memory.
What you could do, is to use single instance class: Design Patten SingleTon
2022 Mar 25 12:55 PM
Hi Frederic, thanks for your answer.
I was also already thinking about using singleton pattern. But this would mean I have to avoid using BADIS at all and handle the creation via factory method/class. Right?
2022 Mar 25 12:59 PM
Yep, it will be easier to use a Factory, and if you have criteria for implementation, you could use the factory to manage MultiTon (multiple singleton, based on criteria you find the right instance)