Issue with Garbage Collecting...I think...

Posted by dbeattie on 17-Jun-2010 10:02

Here is an example of not so great code, but things like this slip in from time to time, and its causing some serious bugs. Basically this code below illustrates what I think is an OpenEdge garbase collecting side effect, and I want to get peoples opinions and experiences. THIS ISN'T CONSISTENT BEHAVIOR, sometimes a set of code will always work until its edited and more classes are added.

I have two external procedures:

GarbageCollectingExample.p: Creates instances of classes, and then returns an error to another external procedure without cleaning up the classes.

TestGarbageCollectingExample.p: Call GarbageCollectingExample.p and reports the ERROR-STATUS.

The problem that I'm seeing is that if I RETURN ERROR "something" without cleaning up the classes, the RETURN-VALUE comes back populated, but ERROR-STATUS:ERROR is FALSE. If I fire ReleaseObjects before I RETURN ERROR, things work correctly.


/* file: TestGarbageCollectingExample.p - Test Garbage Collecting Example */
/*------------------------------------------------------------------------*/
/*
   Calls GarbageCollectingExample.p.
*/
/*------------------------------------------------------------------------*/

RUN GarbageCollectingExample.p NO-ERROR.

MESSAGE "ERROR-STATUS:ERROR:" ERROR-STATUS:ERROR
   VIEW-AS ALERT-BOX
   TITLE "DEVELOPER DEBUG MESSAGE":u.
/*------------------------------------------------------------------------*/
/* end-of-file: TestGarbageCollectingExample.p                            */

/* file: GarbageCollectingExample.p - Garbage Collecting Example          */
/*------------------------------------------------------------------------*/
/*
   This is a simplified procedure that shows the code that is causing error
   during what I think is garbage collecting. It gets called by a test
   test procedure.
*/
/*------------------------------------------------------------------------*/
DEFINE VARIABLE clsError   AS server.class.Error   NO-UNDO.
DEFINE VARIABLE clsLiteral AS server.class.Literal NO-UNDO.
/*------------------------------------------------------------------------*/
RUN SetupObjects NO-ERROR.
IF ERROR-STATUS:ERROR THEN
   RETURN ERROR "Setup Failed...".

RUN GarbageCollectingExample NO-ERROR.
IF ERROR-STATUS:ERROR THEN
   RETURN ERROR "Setup Failed...".

RUN ReleaseObjects NO-ERROR.
 
RETURN.
/*------------------------------------------------------------------------*/
PROCEDURE SetupObjects:

  clsError = NEW server.class.Error() NO-ERROR.
  clsLiteral = NEW server.class.Literal() NO-ERROR.
 
  RETURN.
END PROCEDURE.

PROCEDURE ReleaseObjects:
   
  DELETE OBJECT clsLiteral NO-ERROR.
  DELETE OBJECT clsError NO-ERROR.
   
  RETURN.
END PROCEDURE.

PROCEDURE GarbageCollectingExample:
  DEFINE VARIABLE iTemp AS INTEGER     NO-UNDO.
 
  ASSIGN iTemp = INTEGER("xxx":u) NO-ERROR.
  IF ERROR-STATUS:ERROR THEN
     RETURN ERROR clsError:ErrorMsg(1, TRUE).
 
END PROCEDURE.
/*------------------------------------------------------------------------*/
/* end-of-file: GarbageCollectingExample.p                                         */

All Replies

Posted by dbeattie on 17-Jun-2010 10:03

Forgot to mention I'm running 10.2B01 Windows, but saw the same thing in 10.2A.

This thread is closed