[Openroad-users] Question about the value and use of.InstanceReferences
Joseph C. Kronk
Joseph.Kronk at ingres.com
Thu Nov 15 11:49:07 EST 2007
Hi Peter,
You wrote:
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)
Memory is still claimed by the OpenROAD process even if you NULL your
object references when no longer needed. Memory is allocated in large
blocks and managed within the OpenROAD runtime process. OpenROAD does
not immediately give back unused memory to the operating system (O/S)
but instead puts it on a free list for reuse by other object
instantiations. OpenROAD gives these large blocks back to the back to
the O/S when certain conditions are met and only if the block is
completely unused at the time. It is a good practice to explicitly
NULL any object attributes that reference another object before setting
the object itself to NULL. This will prevent memory leaks caused by
dangling object chains that are part of a circular reference. In
OpenROAD there is not any documented way of explicitly freeing memory
from the 4GL.
-Joe
________________________________
From: openroad-users-bounces at peerlessit.com
[mailto:openroad-users-bounces at peerlessit.com] On Behalf Of Peter van
Bennekom
Sent: Wednesday, November 14, 2007 8:51 AM
To: International OpenROAD Users
Subject: [Openroad-users] Question about the value and use
of.InstanceReferences
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/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.peerlessit.com/pipermail/openroad-users/attachments/20071114/9c2d65f2/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 2926 bytes
Desc: image001.gif
Url : http://www.peerlessit.com/pipermail/openroad-users/attachments/20071114/9c2d65f2/attachment.gif
More information about the Openroad-users
mailing list