A module can be dynamically fetched (loaded) or released (deleted) by a PL/I program using FETCH and RELEASE statements.
A procedure invoked by a procedure reference usually is resident in main storage throughout the execution of the program. However, a procedure can be loaded into main storage for only as long as it is required. The invoked procedure can be dynamically loaded into, and dynamically deleted from, main storage during execution of the calling procedure.
Dynamic loading and deletion of procedures is particularly useful when a called procedure is not necessarily invoked every time the calling procedure is executed, and when conservation of main storage is more important than a short execution time.
The appearance of an entry constant in a FETCH statement indicates that the referenced procedure needs to be loaded into main storage before it can be executed, unless a copy already exists in main storage. Provided the name is referenced in a FETCH statement, a procedure can also be loaded from the disk by:
It is not necessary that control pass through a FETCH or RELEASE statement, either before or after execution of the CALL or function reference.
Whichever statement loaded the procedure, execution of the CALL statement or option or the function reference invokes the procedure in the normal way.
It is not an error if the procedure has already been loaded into main storage. The fetched procedure can remain in main storage until execution of the whole program is completed. Alternatively, the storage it occupies can be freed for other purposes at any time by means of the RELEASE statement.
FETCH and RELEASE have the following rules and features: