instance held in static property

Posted by jmls on 31-Aug-2011 11:32

I'm chasing my tail trying to find an error in my code, and just wanted to ask the question:

If I have a static property that is assigned to an instance of a class, can that instance ever get garbage-collected without a specific delete statement on that instance ?

I have a scenario where a .w is run persistently. During startup, an instance of class foo is assigned to a static public property.

I check for valid-object -

if not this-procedure:persistent then

    wait-for close of this-procedure.

message valid-object(dotr.Maia:Project) view-as alert-box.

in the .w , and this displays "yes". So , at this point all is well. However, I have also put a message in the destructor of the class in question.

As soon as I press "ok" on the message, the destructor message is fired, meaning that the class is now being deleted. However, the call stack only shows the line of the destructor.

As there are no more lines of code being executed in the .w. and no lines showing in the call stack, I can only assume that this instance has been garbage collected. However, it was still assigned to the static property.

Any guesses at what might be happening ?

All Replies

Posted by Peter Judge on 31-Aug-2011 11:50

Any guesses at what might be happening ?

>

Running from procedure editor? Never use it for debugging when you have static stuff ... it explicitly goes out and cleans up after itself, and has no idea that you actually want that reference held :).

-- peter

Posted by Peter Judge on 31-Aug-2011 11:50

You might also add a message in the instance's destructor and check the stack.

-- peter

Posted by jmls on 31-Aug-2011 11:55

no, running from an addon in the toolbar.

However, this may be the issue. Bugger.

Posted by jmls on 31-Aug-2011 11:55

err, I did specifically mention that and said that there was no call

stack apart from the destructor

Posted by Admin on 31-Aug-2011 12:15

Running from procedure editor? Never use it for debugging when you have static stuff ... it explicitly goes out and cleans up after itself, and has no idea that you actually want that reference held .

Yeah, that a bad trap. I never execute OO code from the old ADE anymore.

Posted by jmls on 31-Aug-2011 13:55

so , where do you execute it from ?

Posted by Admin on 31-Aug-2011 14:35

Run configurations in OpenEdge Architect?

Posted by jmls on 31-Aug-2011 14:55

This is not a runtime solution, It's got to interact with the current

progress environment (build / compile / reload editor contents etc)

Posted by Admin on 31-Aug-2011 15:05

Time for an enhancement request I guess...

For persistent procedures there is a trick of having a special internal procedure or function in the PP to save it from AppBuilder's clean up. I doubt it's there for objects - I guess the right way would be having an Interface that tags classes that are o.k. to keep running in the ADE.

But a certain portion of me believes/hopes that there will no manpower be wasted for enhancements to the ADE.

However, it's open source... God bless Dynamics and POSSE! So roll your own AppBuilder

Posted by jmls on 31-Aug-2011 15:10

the only trouble is that it is not appbuilder

I am running this from OEA as an extension that is added to the OEA toolbar.

Posted by Thomas Mercer-Hursh on 31-Aug-2011 15:20

So, why can't you start a fresh AVM?

Posted by jmls on 31-Aug-2011 15:25

because it has to interact with the current OEA session, and I don't

have the eclipse API calls

On 31 August 2011 21:20, Thomas Mercer-Hursh

Posted by Thomas Mercer-Hursh on 31-Aug-2011 16:01

Then, if:

* the purpose is development time behavior and

* the purpose involves interacting with the current AVM

The obvious conclusion is that you either have to rethink your use of statics or you have to expect development involving that static to be painful.

Posted by Peter Judge on 31-Aug-2011 17:43

mikefe wrote:

Time for an enhancement request I guess...

For persistent procedures there is a trick of having a special internal procedure or function in the PP to save it from AppBuilder's clean up. I doubt it's there for objects - I guess the right way would be having an Interface that tags classes that are o.k. to keep running in the ADE.

There's nothing like this for classes. The question came up a while ago (I believe a customer logged a WR about it), and I had thought a enhancement request was logged, but I can't find it now, nor the discussion.

I would agree that there should be a simple interface - IPleaseDontKillMeKindSir ? -  that would signal this. OEA uses adecomm/_runcode.p which is the thing that, um, runs the code. It also does the cleanup. So your wish might be granted.

-- peter

Posted by Admin on 31-Aug-2011 17:53

pjudge schrieb:

mikefe wrote:

Time for an enhancement request I guess...

For persistent procedures there is a trick of having a special internal procedure or function in the PP to save it from AppBuilder's clean up. I doubt it's there for objects - I guess the right way would be having an Interface that tags classes that are o.k. to keep running in the ADE.

There's nothing like this for classes. The question came up a while ago (I believe a customer logged a WR about it), and I had thought a enhancement request was logged, but I can't find it now, nor the discussion.

I would agree that there should be a simple interface - IPleaseDontKillMeKindSir ? -  that would signal this. OEA uses adecomm/_runcode.p which is the thing that, um, runs the code. It also does the cleanup. So your wish might be granted.

-- peter

So it should be pretty easy for an experienced guy like Julian to add that himself.

Posted by Matt Baker on 31-Aug-2011 20:46

Since you have access to adecomm/_runcode.p via possenet download you can work around it with just a few lines of code.

Make a copy, put it in your project/propath, then change it to not kill/ignore objects that implement a specific interface.  The interface doesn't need to have any methods on it.  Or you can run dynamic-invoke no-error on it looking for a specific method being present/not present if you don't want to go the interface route.

Should be pretty straight forward.

For giggles here is the ade code:

http://communities.progress.com/pcom/docs/DOC-106818

And attached is an UNTESTED implementation of IPleaseDontKillMeKindSir.

I've compiled it to r-code so if you can't be bothered to compile it yourself, you can use as is.

mattB

Disclaimer: this code is in no way supported by anyone, anywhere.  It is merely here to demonstrate a technique.  Use at your own risk.

Posted by jmls on 01-Sep-2011 00:33

ah, you are too kind

Posted by jmls on 01-Sep-2011 00:35

the main "surprise" was that I was not expecting the object to be

deleted, as I still had the window open. I'll dig further.

On 31 August 2011 22:02, Thomas Mercer-Hursh

Posted by jmls on 01-Sep-2011 00:36

I'll have a look at that. Thanks

Posted by Admin on 01-Sep-2011 00:45

ah, you are too kind

Man, you are presenting at www.pugchallenge.eu - you are an expert!

Posted by Peter Judge on 01-Sep-2011 07:23

However, it's open source... God bless Dynamics and POSSE! So roll your own AppBuilder

I remember seeing this *waaaaay* back in the day ...  http://sourceforge.net/projects/openappbuilder/

-- peter

Posted by jmls on 01-Sep-2011 07:30

heh! lol.

them were the days

This thread is closed