Use the FREEMAIN macro to free one or more areas of virtual storage. You can also use the FREEMAIN macro to free an entire virtual storage subpool if it is owned by the task under which your program is issuing the FREEMAIN. For more information on releasing a subpool, see the chapter about virtual storage management in z/OS MVS Programming: Assembler Services Guide.
You can also use the STORAGE macro to free storage, even if the storage was obtained using the GETMAIN macro. Compared to FREEMAIN, STORAGE provides an easier-to-use interface and has no restrictions or locking requirements. See the chapter about virtual storage management in z/OS MVS Programming: Authorized Assembler Services Guide for a comparison of FREEMAIN and STORAGE.
The FREEMAIN macro is also described in z/OS MVS Programming: Assembler Services Reference ABE-HSP, with the exception of the BRANCH parameter.
The FREEMAIN macro provides two types of entry linkage: SVC entry and branch entry. If you do not specify the BRANCH parameter, the FREEMAIN service receives control through SVC entry. If you specify the BRANCH parameter, the FREEMAIN service receives control through branch entry.
The requirements for the caller are:
Environmental factor | Requirement |
---|---|
Minimum authorization: | For subpools 0-127: problem state and PSW key
8-15. For subpools 131 and 132, one or more of the following:
For other subpools, one or more of the following:
To issue a subpool release for subpool 0: PSW key 0. For branch entry: supervisor state and PSW key 0. |
Dispatchable unit mode: | For SVC entry: task. For branch entry: task or SRB. |
Cross memory mode: | For SVC entry: PASN=HASN=SASN. For branch entry: any PASN, any HASN, any SASN. |
AMODE: | For SVC entry: 24- or 31- or 64-bit. For branch entry: 24- or 31-bit.
|
ASC mode: | For BRANCH=(YES,GLOBAL), primary or access register
(AR). For all other requests, primary. Callers in AR mode must use BRANCH=(YES,GLOBAL) and can obtain only global (common) storage. |
Interrupt status: | For BRANCH=(YES,GLOBAL), disabled for I/O and external interrupts. For all other requests, enabled for I/O and external interrupts. |
Locks: |
|
Control parameters: | For LC, LU, L, VC, VU, V, EC, EU, E requests: control parameters must be in the primary address space. For other requests: control parameters are in registers. |
Before issuing the FREEMAIN macro in AR mode, issue SYSSTATE ASCENV=AR.
Before issuing the FREEMAIN macro without the BRANCH parameter (SVC entry), the caller does not have to place any information into any register unless using it in register notation for a particular parameter, or using it as a base register.
Set GPR 4 to 0 or the address of a TCB in the currently addressable address space. Setting GPR 4 to 0 identifies the input TCB as the TCB that owns the cross-memory resources for the currently addressable address space (task whose TCB address is in ASCBXTCB).
For an explanation of the term input TCB, and to determine system-assigned defaults for private storage ownership, see the topic about selecting the right subpool for virtual storage requests in z/OS MVS Programming: Authorized Assembler Services Guide.
Before issuing the FREEMAIN macro with BRANCH=(YES,GLOBAL), you are not required to place any information into any register unless using it in register notation for a particular parameter, or using it as a base register.
Some callers depend on register contents remaining the same before and after issuing a service. If the system changes the contents of registers on which the caller depends, the caller must save them before issuing the service, and restore them after the service returns control.
None.
The standard form of the FREEMAIN macro is written as follows:
Syntax | Description |
---|---|
name | name: symbol. Begin name in column 1. |
␢ | One or more blanks must precede FREEMAIN. |
FREEMAIN | |
␢ | One or more blanks must follow FREEMAIN. |
LC,LA=length addr | length addr: A-type address, or register (2) - (12). |
LU,LA=length addr | |
L,LA=length addr | |
VC | |
VU | |
V | |
EC,LV=length value | length value: symbol, decimal number, or register (2) - (12). |
EU,LV=length value | |
E,LV=length value | |
RC,LV=length value | If R, RC, or RU is specified, register (0) may also be used. |
RC,SP=subpool nmbr | subpool nmbr: symbol, decimal
number 0-255, or register (2) - (12). If R is specified, register
(0) may also be used. Note: For a subpool release (RC,SP or RU,SP,
or R,SP), no other parameters except RELATED and BRANCH=YES can be
specified.
|
RU,LV=length value | |
RU,SP=subpool nmbr | |
R,LV=length value | |
R,SP=subpool nmbr | |
,A=addr | addr: A-type address, or register (2) - (12). If R, RC, or RU is specified, register (1) can also be used. |
Note: If R, RC, or RU is specified, register (1)
can also be specified.
|
|
,SP=subpool nmbr | subpool nmbr: symbol, decimal number 0-255, or register (2) - (12). |
Default: SP=0. If R is specified, register (0) may also be used. | |
,BRANCH=YES | Note: BRANCH=(YES,GLOBAL) may be specified only with RC or RU. |
,BRANCH=(YES,GLOBAL) | |
,KEY=number | nmbr: decimal numbers 0-15, or register (2) - (12). |
Note: KEY may be specified only with RC or RU.
|
|
,RELATED=value | value: any valid assembler character string. |
The parameters are explained as follows:
LC, LU, and L indicate conditional (LC) and unconditional (LU and L) list requests and specify release of one or more areas of virtual storage. The length of each virtual storage area is indicated by the values in a list beginning at the address specified in the LA parameter. The address of each of the virtual storage areas must be provided in a corresponding list whose address is specified in the A parameter. All virtual storage areas must start on a doubleword boundary.
VC, VU, and V indicate conditional (VC) and unconditional (VU and V) variable requests and specify release of single areas of virtual storage. The address and length of the virtual storage area are provided at the address specified in the A parameter.
EC, EU, and E indicate conditional (EC) and unconditional (EU and E) element requests and specify release of single areas of virtual storage. The length of the single virtual storage area is indicated in the LV parameter. The address of the virtual storage area is provided at the address indicated in the A parameter.
For an unconditional request, the system abnormally ends the active task if the FREEMAIN request cannot be successfully completed.
LA specifies the virtual storage address of one or more consecutive fullwords starting on a fullword boundary. One word is required for each virtual storage area to be released; the high-order bit in the last word must be set to 1 to indicate the end of the list. Each word must contain the required length in the low-order three bytes. The fullwords in this list must correspond with the fullwords in the associated list specified in the A parameter. The words must not be in the area to be released. If this rule is violated and if the words are the last allocated items on a virtual page, the whole page is returned to storage and the FREEMAIN abends with an X'0C4' abend code.
BRANCH=YES allows both local (private area) and global (common area) storage to be released. See Input register information for BRANCH=YES for specific information on input register requirements.
BRANCH=(YES,GLOBAL) allows only global storage to be released. With BRANCH=(YES,GLOBAL), the SP parameter may designate only subpools 226-228, 231, 239, 241, 245, 247, or 248. BRANCH=(YES,GLOBAL) is valid only with RC or RU.
Abend codes FREEMAIN might issue are listed below in hexadecimal. For detailed abend code information, see z/OS MVS System Codes.
When the FREEMAIN macro returns control to your program and you specified a conditional request, GPR 15 contains one of the following hexadecimal return codes:
Return Code | Meaning and Action |
---|---|
0 | Meaning: Successful completion. Action: None. |
4 | Meaning: Program error. Not all requested
virtual storage was freed. Action: Check your program for
the following kinds of errors:
|
8 | Meaning: Program error. No virtual storage
was freed because part of the storage area to be freed is fixed. Action:
Determine whether you have made one of the following errors. If so,
correct your program and rerun it:
|
FREEMAIN RC,LV=400,A=(1),SP=10
FREEMAIN RU,SP=3
FREEMAIN LU,LA=LNTHLIST,A=AREAADD,SP=5
.
.
.
LNTHLIST DC F'200',F'800',X'80',FL3'32'
AREAADD DS 3F
FREEMAIN EC,LV=400,A=(2),BRANCH=YES
FREEMAIN RU,LV=48,A=(5),SP=231,KEY=(3),BRANCH=(YES,GLOBAL)