The following code example can be used to detect objects which are left in memory.
- This code is most useful for debugging memory leaks on AppServer and Webspeed agents
- The objects that can be checked are those exposed by the SESSION:FIRST-* properties.
- Walks the widget trees that the ABL makes available and dumps out basic information on the objects which have been left in memory.
- Since it runs within a single OpenEdge session (client, AppServer agent, WebSpeed agent), it will only report objects for that specific session.
- This code uses the MESSAGE statement to ensure that when run on the AppServer the results will be available in the AppServer server log file (assuming, that the loggingLevel is set to either Verbose or Extended).
- The code inside of each DO WHILE block can be changed into the appropriate DELETE statement in order to make this program into a quick & dirty tool to release leaked resources on the AppServer so that the AppServer does not have to be shut down and restarted. Just make the code change then from a 4GL client, run this program on the AppServer.
- This code was designed to work on OpenEdge 10.1x and later releases. To use this code with an older release, remove the code that references SESSION attributes that do not exist in earlier releases.
DEFINE VARIABLE hTemp AS HANDLE NO-UNDO.
DEFINE VARIABLE hObject AS HANDLE NO-UNDO.
DEFINE VARIABLE vTemp AS CHARACTER NO-UNDO.
DEFINE VARIABLE oObject AS Progress.Lang.Object NO-UNDO.
DEFINE VARIABLE oTemp AS Progress.Lang.Object NO-UNDO.
ASSIGN hObject = SESSION:FIRST-DATASET.
DO WHILE hObject <> ?:
ASSIGN hTemp = hObject
hObject = hObject:NEXT-SIBLING.
MESSAGE 'ProDataSet, Handle=' hTemp
', Name=' hTemp:NAME
', Dynamic=' hTemp:DYNAMIC VIEW-AS ALERT-BOX.
END.
ASSIGN hObject = SESSION:FIRST-DATA-SOURCE.
DO WHILE hObject <> ?:
ASSIGN hTemp = hObject
hObject = hObject:NEXT-SIBLING
vTemp = (IF hTemp:QUERY = ? THEN ? ELSE hTemp:QUERY:PREPARE-STRING).
MESSAGE 'DataSource, Handle=' hTemp
', Name=' hTemp:NAME
', Query=' vTemp VIEW-AS ALERT-BOX.
END.
ASSIGN hObject = SESSION:FIRST-BUFFER.
DO WHILE hObject <> ?:
ASSIGN hTemp = hObject
hObject = hObject:NEXT-SIBLING.
MESSAGE 'Buffer, Handle=' hTemp
', Name=' hTemp:NAME
', Table=' hTemp:TABLE
', Dynamic=' hTemp:DYNAMIC
', DataSet=' hTemp:DATASET VIEW-AS ALERT-BOX.
END.
ASSIGN hObject = SESSION:FIRST-PROCEDURE.
DO WHILE hObject <> ?:
ASSIGN hTemp = hObject
hObject = hObject:NEXT-SIBLING.
MESSAGE 'Procedure, Handle='hTemp
', Name=' hTemp:NAME VIEW-AS ALERT-BOX.
END.
ASSIGN hObject = SESSION:FIRST-QUERY.
DO WHILE hObject <> ?:
ASSIGN hTemp = hObject
hObject = hObject:NEXT-SIBLING.
MESSAGE 'Query, Handle=' hTemp
', Name=' hTemp:NAME
', Dynamic=' hTemp:DYNAMIC
', Query=' hTemp:PREPARE-STRING VIEW-AS ALERT-BOX.
END.
ASSIGN oObject = SESSION:FIRST-OBJECT.
DO WHILE oObject <> ?:
ASSIGN oTemp = oObject
oObject = oObject:NEXT-SIBLING.
MESSAGE 'Object, Name=' oTemp:ToString() VIEW-AS ALERT-BOX.
END.
In addition to the above, the
Dynamic Objects View of the Debugger allows tracking the creation of dynamic handle-based ABL objects such as dynamic queries and buffers, and persistent procedures. This allows verification that these objects are being deleted as needed and that application code is not creating memory leaks by leaving objects running when they’re no longer used.
The following tutorial demonstrates:
- How to use the Dynamic Objects View
- How to enable dynamic object monitoring from Architect:
After recording these videos the name for
OpenEdge Architect was changed to
Progress Developer Studio for OpenEdge (PDSOE). As you view these videos, especially if you are working with OpenEdge 11.0 or later, please keep this name change in mind.
https://community.progress.com/community_groups/openedge_general/w/openedgegeneral/1197.openedge-architect-video-monitoring-dynamic-objects-in-the-debugger