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: 

What does "Freed stack:" mean?

Former Member
0 Kudos

Hello,

Can anyone explain to me, what "Freed stack:"

in the ABAP debugger means?

Example:

af_t_event_mdata FREED STACK:

Thanks and cheers,

Rolf

6 REPLIES 6

Former Member
0 Kudos

Freed Stack means the resources of the program are "freed" after completion of the program stack.

all resources are to be freed for that stack.

Vinodh Balakrishnan

0 Kudos

I have a class, which draws an alv grid. In the ONF4 event,

I create dialog box using the CL_GUI_DIALOGBOX_CONTAINER class.

During the ONF4 event, I still have the reference to the event_data.

I store the event_data, that I receive from the ONF4 event

as an attribute in my main class. Then I implemented

a DOUBLE_CLICK event, which handles the double click

in the dialog box. It is in this event, where I get the

Freed Stack and don't find the reference to event_data anymore.

How do I keep avoiding that?

Thanks,

Rolf

0 Kudos

Hi Rolf,

did you solve the problem meanwhile?

I've the same problem performing a special EXCEL export - in other systems I could access the data table of an ALV-Grid (CL_GUI_ALV_GRID) but now I have the "freed stack" problem in a customer system - so I have no access to me->mt_outtab->* content.

thx

br

Gernot

0 Kudos

Hi,

seems that I solved the problem after I went trough some hints in abap forums.

Unbelievable but true - in my case the problem was that I've tried to avoid global data.

Means:

The ALV class uses MT_OUTTAB as reference to DATA - so when I replaced my local data object with a global internal table in my function group it worked just fine.

br

Gernot

That makes perfectly sense, and I just realised it since I had the same issue: the lifetime of a local variable (in my case in a method) determines how long it will live, and so any reference to it.

Hence if you put data (a "select into table" in my case) inside a local var, and return a reference of it, your caller will get nothing (FREED STACK), while if you put data into something that "still lives" (e.g. an instance attribute of your class, given that this class instance lives...), you will get the data.

To make a long story short: if the REAL variable lives, the reference lives as well.

If the REAL variable dies, any reference dies with it.

Looks trivial, and it's no magic at all.

Cheers

Alex

pavan_prabhu
Active Participant
0 Kudos

Hello Rolf,

Local variables follow this pattern; when a method is entered, its local variables come alive. When that method calls another method, the new method's local variables come alive. They'll be dead before the first method's local variables are dead. We use stacks for temporary storage because they are really cheap and easy.

ABAP is a safely typed language. In ABAP, you cannot access any address outside the scope.

In your case, the address you are accessing is no longer valid. It doesn't work because ABAP compiler has freed the stack memory after ONF4 event returned and the reference variable doesn't contain anything when you have entered the Double click event. These both events have their own scopes.

Hence the workaround which you can try is to capture the event_data and put it in a global variable.

And get the reference of this variable and use it in your main class.This makes sense because the life time of global variable stays till program has finished its execution.