[Openroad-users] Question about the value and use of.InstanceReferences
Antill, Jim
jantill at revenue.ie
Thu Nov 15 20:38:17 EST 2007
Hi,
I guess it would be difficult to use the instanceReference counter to control
when a piece of clean-up code for an object should take place, or to do
anything useful really as it can't be interpreted properly by code given the
available information. For example, as well as references to the object from
your code you could also well have other objects eligible for garbage
collection that are referencing the object. So, an object could have it's
instanceReference set to any number but still be eligible for garbage
collection (as all the things referencing it are eligible for garbage
collection).
Maybe we need a method on objects that is triggered automatically immediately
before garbage collection, something like the "finalize" method in Java. This
would enable any clean-up to be done before the object is dispensed with for
good. Having said that, I'm not sure how useful it would be for a couple of
reasons. Firstly, you can't tell when garbage collection is going to take
place (something that should be up to the discretion of OR). It could also
lead to other complex scenarios such as the code in the called block making
the object no longer eligible for garbage collection e.g assigns it's
reference to a global variable etc.
On the face of it the instanceReference counter seems useful but maybe isn't
particularly. Now, having access to information such as which objects are
referring to a particular object (enabling a reference tree to be observed)
would be an entirely different matter - extremely useful particularly for
debugging. Graphical debuggers showing object relations could be enhanced no
end. Is this information available anywhere?
Regards,
Jim
-----Original Message-----
From: openroad-users-bounces at peerlessit.com
[mailto:openroad-users-bounces at peerlessit.com]On Behalf Of Peter van Bennekom
Sent: 14 November 2007 16:51
To: International OpenROAD Users
Subject: [Openroad-users] Question about the value and use
of.InstanceReferences
*************************************
This e-mail has been received by the Revenue Internet e-mail service. (IP)
*************************************
Folks,
I have noticed that this attribute reflects the number of instances pointing
to this object at runtime - not only does it hold the number of references in
the code but it also reflects when OpenROAD points to it. Example:
PROCEDURE ir_test() =
Declare
ir_object = ir_class;
EndDeclare
Begin
Curprocedure.trace( text = 'proc before call: ' + varchar(
ir_object.InstanceReferences ) );
Ir_object.showIR();
Curprocedure.trace( text = 'proc after call: ' + varchar(
ir_object.InstanceReferences ) );
End;
Ir_class is userclass with two methods:
METHOD showIR() =
Begin
Curmethod.trace( text = 'showIR: ' + varchar(
curObject.InstanceReferences ) );
End;
METHOD showMore() =
Begin
Curmethod.trace( text = 'showMore: ' + varchar(
curObject.InstanceReferences ) );
End;
Output is as follows:
proc before call: 1
showIR: 2
showMore: 3
proc after call: 1
One can argue about the value of this kind of increment and decrement. If
one would like to implement a concept of freeing memory when object is not
needed anymore (circular references i.e. but also NULLing pointer from self -
we have found that sometimes when you do not null pointers when not needed
anymore memory is still claimed) based on the instanceReferences attribute
one would find out this is impossible. One would like to see how many
references the code has (1 in this little example) so implementing above
mentioned concept can be done.
My questions to the group are: are you using this attribute, if so: how are
you using it and do you have to jump through hoops to get what you want? If
you are consciously not using it what kept you from using it?
Thanks,
Peter
Peter van Bennekom | Sr. Principal Architect | Infor | office: 610-407-8113 |
fax: 610-407-8027 | mailto:peter.vanbennekom at infor.com
<http://www.infor.com/>
************************
This message has been delivered to the Internet by the Revenue Internet e-mail service (OP)
*************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.peerlessit.com/pipermail/openroad-users/attachments/20071115/44721313/attachment.html
More information about the Openroad-users
mailing list