Consultor Eletrônico



Kbase 19730: 4GL. Why Don't Buffer Field Handles Need to be Released?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   8/21/2003
Status: Unverified

GOAL:

4GL. Why Don't Buffer Field Handles Need to be Released?

FIX:

An often asked question is why can a single variable be defined
(as a handle) to hold buffer field handles and does not need cleaning
as do buffer and query objects.

Reference counting to hang onto objects is not used in the Progress 4GL. The reason is that you could have for example, a temp-table with 1000 records in it, each one with an object handle. If the 4GL did reference counting, you would have to get each object handle out and dereference with it before you could delete the temp-table.

Performance would be disastrous.

Instead, you can copy object handles as much as you want.

There is only one object. If you have for example, six handles to it but delete it with just one, the object is marked as "stale" by zeroing its magic number, and then it is freed.

All the handles including the one you deleted it with still point at the object, but 4GL checks the handle for validity each time you use it. You should get INVALID-HANDLE for it (The VALID-HANDLE function is also present for this purpose.)

The VALID-HANDLE function also detects freed memory on Windows NT.

On UNIX there actually is a handle in a map which is deleted when the
object is deleted.

In addition, most database objects have a unique-ID so you can make sure some other object did not get allocated in the exact same spot as a stale one (thus defeating the VALID-HANDLE mechanism on Windows NT -- but not on UNIX).

In practice this is much harder to do since database objects (like most in a graphical user interface) get allocated in a widget-pool. When the widget-pool goes away, the objects are automatically deleted. Database objects that correspond to static buffers/queries, etc. also automatically disappear when their object goes out of scope.

In summary, an object can easily be deleted without the user being aware of it. If its handle is from a higher scope, it will go stale.