Created On:  23 August 2012

Problem:

When an ACUCOBOL-GT runtime terminates, all dynamically allocated memory is released. There are two situations where this is not true: CALL PROGRAM "program" using and CHAIN "program" using .......

Both terminate the current runtime but do NOT release dynamically allocated memory. This has been found to cause various problems including "Illegal Operation" errors and other unexpected results. For this reason, if you are using CALL PROGRAM or CHAIN, be sure to DESTROY all bitmaps, fonts (except those accepted from "standard object") and menus which have been created by that run unit. The exception here is any of these whose handles you may be passing in the USING section which you want to use in the called program.

A second area which can cause problems is the situation where a subroutine is called several times, and each time it allocates memory by one or more of the above means. If prior to the EXIT PROGRAM you have not DESTROYED these items, then when the subroutine is called again, you end up reallocating this memory. Note that even if the subroutine is CANCELLED, the memory for these items is NOT freed. This causes a "memory leak" where the program starts using up memory. Again, we have found that sometimes this can cause "Illegal Operation" errors or other unexpected results.

Resolution:

These are important considerations when programming with ACUCOBOL-GT. One way of determining whether or not a "memory leak" is occurring is to use the "U" option in debugger. Place a breakpoint just before the EXIT PROGRAM in a subroutine and each time you reach it enter "U". The amount of memory being used should be approximately the same each time. If you see it increasing then you have a memory leak someplace in that routine and the code should be examined for the above mentioned causes.