Application Development 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: 

How to free all the objects and variables of an ABAP programme?

Former Member
0 Kudos

Hi,

I want to free all the memory that my programme uses at a certain step. Is there a function or command for it?

Best Regards.

1 ACCEPTED SOLUTION

Lakshmant1
Active Contributor
0 Kudos

Hi Fuat,

Have a look at FREE Keyword.

Thanks

Lakshman

6 REPLIES 6

Lakshmant1
Active Contributor
0 Kudos

Hi Fuat,

Have a look at FREE Keyword.

Thanks

Lakshman

Former Member
0 Kudos

Hi Fuat,

additionally check the keyword unassign for field-symbols and use the free method of your created objects.

regards

Siggi

former_member183804
Active Contributor
0 Kudos

No there is no general approach nor a functionality. One have to distinguish at least following cases:

1.) If your data objects reside on the stack (local variables) they are cleared automatically if you leave the modularization unit (e.g. form routine).

2.) if one uses global variables or statics, they can be reset with free / or clear commands.

3.) if you used create data / create object and references things may turn out not to be that easy. For example static class members act like global variables for the internal session. In that case one has to do clear on all static members.

If you want to be really sure maybe you should do a rfc call with destination 'NONE' or use submit + import/export. Both techniques will open a new session which will be finally closed. By closing the session the ABAP runtime will release any allocated memory. But of course thats not granted for free.

kind Regards

Klaus

Former Member
0 Kudos

Hello Fuat,

There are a few points that I would like to mention here -

1. ABAP provides Automatic Garbage Collection - i.e., all the memory that is no longer in use will be reclaimed from the heap automatically.

2. When you say that you want to free all the memory that is occupied by a program, how do you expect the program to continue to run? What you are asking for is to make the program kill itself.

However, there's one thing that you can do, which would immediately free all the memory that the program had ever used - Use a message of Type X.

4. If you are referring to the individual variables (I'm referring to ordinary variables, not internal tables and objects) and the memory they occupy, I'm afraid you cannot free them so long as they continue to exist in the scope.

5. The best way to have control over your program memory is to make everything completely object oriented. And also use subroutines as far as possible.

Regards,

Anand Mandalika.

Former Member
0 Kudos

Is there a particular problem that you are trying to solve? Could you provide additional detail?

Former Member
0 Kudos

The problem is that:

even the programme finishes processing the memory it allocates is not freed when it returns to selection screen. And when it runs again the memory it allocates is doubled.

Finnally I found its cause. I have to free the session I created for the livecache. By using the FM /SAPAPO/RRP_SIMSESSION_LEAVE I succeeded it.

Thanks to all.