Consultor Eletrônico



Kbase P155379: How does ABL garbage collection work?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   09/11/2009
Status: Unverified

GOAL:

How does ABL garbage collection work?

GOAL:

What is OpenEdge garbage collection?

GOAL:

How to prevent garbage collection from deleting objects?

FACT(s) (Environment):

OpenEdge 10.2A
Windows

FIX:


Garbage collection is an automatic system management feature whereby OOABL objects are destroyed when the count of other objects referring to them is zero.

- It only applies to OOABL objects including user-defined objects, system generated error objects, and .NET objects.
- Uses reference counting (counts all references of objects assigned to variables, or temp-tables).
- When reference count for an object goes to zero it is added to a list of 'objects to be destroyed'.
- System destroy objects at indeterminate intervals.
- Garbage collection on an AppServer will be run before the switch to a different context.
- If an object reference is defined with UNDO and is removed during a transaction, garbage collection will be postponed until the end of the transaction.

Why would you need to prevent garbage collection from deleting objects?

You may for example, have a class acting as a singleton and you need to ensure that the object is not deleted in the session.

1. Store in the object reference to itself:

CLASS nevergarbage:
DEFINE VARIABLE me AS Progress.Lang.Object.
CONSTRUCTOR PUBLIC nevergarbage():
me = THIS-OBJECT.
END.
END CLASS.

2. Have multiple objects referring to one another in a circular fashion.

3. Use client startup parameter -nogc to disable garbage collection.

Troubleshooting:
- The ABL profiler may show a statement taking longer to execute due to garbage collection.
- Garbage collection does not force the Debugger to step into the destructor unless a breakpoint exists.