Question Delete Handle Of Buffer

OpenEdge 11.5.1
Linux

Code:
define variable hQuery as handle no-undo.

hQuery:set-buffers(BUFFER custom:HANDLE).

hQuery:query-open().
.
.
.
delete object hQuery.


My question here is, after the "delete hQuery" command, does the buffer itself remain in memory or cleared?

I ask this question because our system has a regular dynamic buffer leak issue with the maximum number of buffers exceeded.
 

Stefan

Well-Known Member
buffer custom:handle is a handle to a static buffer, so will not leak - you can verify this yourself if you start the debugger and then use monitor dynamic objects.
 

RealHeavyDude

Well-Known Member
Only handle-based objects that you instantate at runtime with the CREATE statement can cause memory leaks when their are not managed correctly. If you grab the handle to a static object ( like in your example the handle to the default static buffer that comes with every table / temp-table you reference in your program ) the ABL automatically takes care and removes them when the procedure that referenced them goes out of scope.

If you instantiate handle-based objects dynamically at runtime and do not explicitely scope them to a widget-pool, they will automatically be scoped to the unnamed widget-pool of the ABL session - meaning they are destroyed when the session ends. An easy solution to have ALL such handle-based dynamics objects automatically scoped to the unnamed widge-pool of the procedure that instantiates them is to put the "create widge-pool no-error." statement at the beginning of the procedure. This does not prevent memory leaks when you - for example - create such objects repeatedly in a loop, but it ensures that they are destroyed when the procedure goes out of scope - similarily like static objects.

I once consulted a Progress customer that had a serious issue in that the AppServer needed to be restarted on a regular basis ( every 3 hours or so ) due to memory leaks. Adding the "create widget-pool no-error." statement at the beginning of all procedures which ran on the AppServer solved the issue as the regular restarts were not necessary anymore. Nevertheles, you need to manage the handle-based dynamic objects you create at runtime. You can manage them with widget-pools or you can execute the "delete object ..." statement when you don't need them anymore. Therefore doing nothing is like managing them in the unnamed widget-pool that comes with the ABL session - but that I would not recommend.


Heavy Regards, RealHeavyDude.
 
Top