Application Development and Automation 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: 
Read only

Destruct static instance

Former Member
0 Likes
1,154

HI all

There is a way to kill instance of static method? (not my class and i cant change it )

in the class there is method get instance and I want that in RT process (during one session call ) to get new instance.

I would like to do that during RT process ,like destruct in other language .

I know that this is now simple but maybe there is a way in abap ....

Thanks,

Joy

Edited by: Joy Stpr on Oct 6, 2011 5:43 PM

1 ACCEPTED SOLUTION
Read only

MarcinPciak
Active Contributor
0 Likes
948

Garbage collector will delete object which once there is no reference pointing to it (so simply ensure you remove all references). This is the only way to destruct the object in ABAP.

Regards

Marcin

4 REPLIES 4
Read only

MarcinPciak
Active Contributor
0 Likes
949

Garbage collector will delete object which once there is no reference pointing to it (so simply ensure you remove all references). This is the only way to destruct the object in ABAP.

Regards

Marcin

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
948

Hello Marcin,

If i understand correctly the OP is facing this problem because "singleton" pattern is implemented in the class!

Also afaik developer cannot trigger the Garbage Collector. So i was thinking if we can use the [C-destructor |http://help.sap.com/abapdocu_702/en/abenc_destructor.htm]call to destroy the static instance attribute of this class?

Let me know your thoughts.

BR,

Suhas

Read only

0 Likes
948

Hi Suhas,

Documentation of C-destuctor (nice to know that there is something like that) says it should only be used in special cases and for internal use only. I think the easies would be simply "unbinding" this static attribute which would cause Garbage Collector to pick refering object (itself) and delete it. I didn't say GC needs to be called directly

Regards

Marcin

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
948

Hey Marcin,

I didn't say GC needs to be called directly

I bet you didn't

I'm yet to understand GC's clandestine operations ... He he

Cheers,

Suhas