FREE STORAGE (COBOL)

The FREE STORAGE statement releases all or part of a variable storage area. The storage must have been acquired by a GET STORAGE request in the issuing task or by another task running on the same terminal as the issuing task. A partial release is valid only for user storage; shared storage must be freed in its entirety.
idmscu
The FREE STORAGE statement releases all or part of a variable storage area. The storage must have been acquired by a GET STORAGE request in the issuing task or by another task running on the same terminal as the issuing task. A partial release is valid only for user storage; shared storage must be freed in its entirety.
Syntax
►►─── FREE STORAGE ───────────────────────────────────────────────────────────►  ►─┬─ STGID 
storage-id 
────────────────────────────────────────────────┬─ . ──►◄    └─ FOR 
01-level-storage-data-loc
 ─┬───────────────────────────────┬─┘                                      └─ FROM 
start-free-storage-loc
 ─┘
Parameters
  • STGID 
    storage-id
    Specifies the variable storage area to release. Specify the symbolic name of a user-defined field that contains the ID, or the ID itself enclosed in quotation marks.
  • FOR 
    01-level-storage-data-loc
    Specifies the LINKAGE SECTION entry of the storage area.
  • FROM 
    start-free-storage-loc
    Specifies the starting point of the release. Specify the symbolic name of a user-defined field that contains the starting point of the storage area. The storage is released from the specified location to the end of the storage area. 
Example
The following example releases the storage area that is identified by 09PA:
FREE STORAGE STGID '09PA'.
Status Codes
After completion of the FREE STORAGE function, the ERROR-STATUS field in the IDMS-DC communications block indicates the outcome:
Status code
Meaning
0000
The request has been serviced successfully.
3213
The requested storage ID cannot be found.
3232
The derived length of the variable storage area is zero or negative.
3234
The request cannot be serviced because the variable storage area is not an 01-level entry in the LINKAGE SECTION.