[Progress Communities] [Progress OpenEdge ABL] Forum Post: Implicitly created TTs not deleted when returning with an error

  • Thread starter Thread starter jbijker
  • Start date Start date
Status
Not open for further replies.
J

jbijker

Guest
Whenever you pass table handles to a procedure I'm aware that a new implicit TT is created when the procedure is called, and you need to do handle the cleanup of this implicit created TT. This cleanup works well if no error is returned. However I've noticed that if you return with an error from the procedure, with the cleanup code in a finally block, for some reason this implicit created TT is NOT deleted, giving memory leaks. See below code to reproduce. If you want to run without raising an error just change the second parameter on line 9 from INPUT TRUE to INPUT FALSE. In short we have a temp-table, and we're passing the temp-table handle over to procedure doTableLogic. Inside this procedure we have code that handles the clean-up of the implicit created temp-table in the FINALLY block. After this we scan all buffer handles in the session to see if we have any buffer handles remaining (procedure scanLeaks), and if we find one we report on it & delete it. If we run the procedure without raising an error no memory leaks are reported, but whenever you run it and it returns with an error we get a memory leak. Can anyone explain this, or ways to handle the cleanup better, or is this a Progress bug? Tested on OE 11.3, 11.6 & 11.7. DEFINE TEMP-TABLE ttTest NO-UNDO FIELD cValue AS CHARACTER. DEFINE VARIABLE hTable AS HANDLE NO-UNDO. ASSIGN hTable = TEMP-TABLE ttTest:HANDLE. MESSAGE "initial hTable:" hTable hTable:DEFAULT-BUFFER-HANDLE. RUN doTableLogic(INPUT-OUTPUT TABLE-HANDLE hTable, INPUT TRUE) NO-ERROR. IF ERROR-STATUS:ERROR THEN MESSAGE "doTableLogic error:" RETURN-VALUE. RUN scanLeaks(INPUT SESSION:FIRST-BUFFER). PROCEDURE doTableLogic: DEFINE INPUT-OUTPUT PARAMETER TABLE-HANDLE iphTTBuffer. DEFINE INPUT PARAMETER iplReturnError AS LOGICAL NO-UNDO. DEFINE VARIABLE cError AS CHARACTER NO-UNDO. MESSAGE "iphTTBuffer:" iphTTBuffer. IF iplReturnError THEN ASSIGN cError = "sorry". FINALLY: /* delete the implicit created TT */ IF VALID-HANDLE(iphTTBuffer) THEN DELETE OBJECT iphTTBuffer. IF cError > "" THEN RETURN ERROR cError. END FINALLY. END. PROCEDURE scanLeaks: DEFINE INPUT PARAMETER iphHandle AS HANDLE NO-UNDO. IF VALID-HANDLE(iphHandle) THEN DO: MESSAGE "Handle Leak" iphHandle iphHandle:TABLE-HANDLE iphHandle:NAME. /* recurse to find all */ RUN scanLeaks(INPUT iphHandle:NEXT-SIBLING). /* clean up */ DELETE OBJECT iphHandle:TABLE-HANDLE. END. END.

Continue reading...
 
Status
Not open for further replies.
Back
Top