Memory Management

This help section discusses how ACUCOBOL-GT manages runtime memory, the tools available to you to help manage program memory, and the facilities available to help find and correct memory management problems.

When runcbl initiates, it loads the main program into memory and begins execution. As other programs are called they are also loaded into memory. Once loaded, a program remains in memory until it is canceled (typically with the CANCEL statement). Canceling a program:

This handling allows for a full ANSI implementation of subprograms (variables retain their previous values when a subprogram is re-entered, files can be left open in a subprogram, and so forth).

If subprograms are never canceled, a large system can eventually occupy very substantial amounts of memory. This is a common problem with large menu driven applications where the master menu calls programs for the various menu selections.

There are several mechanisms for managing runtime memory, including the CANCEL verb and the INITIAL and RESIDENT clauses of the PROGRAM-ID paragraph. To provide more flexibility, you can also enable a caching system in which canceled programs are not removed from memory until a specified memory limit is reached (see CANCEL below).