Determining When CMS Reclaims Resources

To summarize, there are five ways that programs implicitly release resources:

  1. At module creation — When you use the CMS GENMOD command to create a MODULE file, you can use the CLEAN/NOCLEAN option to indicate whether you want a module to be cleaned from storage. CLEAN is the default for relocatable modules. NOCLEAN is the default for nonrelocatable modules.
  2. At SVC 202/CMSCALL termination — By default, CMS reclaims resources at SVC 202/CMSCALL termination (end-of-SVC), the point when CMS returns control from the called routine to the caller.
  3. At end-of-command — If CMS does not reclaim resources at SVC 202/CMSCALL termination, it reclaims them at end-of-command (Ready;).
  4. Abend processing — When a program terminates abnormally, CMS reclaims resources allocated while the program was running, terminates the various SVC levels, and returns control back to the command loop.
  5. At logoff — when a user issues the LOGOFF command, all resources associated with the virtual machine are released.

SVC 202/CMSCALL termination and end-of-command can be thought of as program boundaries. Programs on one side of the boundary need not worry about resources created by programs on the other side.

If the program is a multitasking program, it is run in a new process. At end-of-SVC, the process is deleted and process-affiliated resources are cleaned up.

Figure 1 illustrates the boundary relationship CMS environment1. The numbers in the drawing indicate the sequence of events:
Step 1
User begins a z/VM® session by logging on.
Step 2
Command cycle begins when cmd 1 is issued.
Step 3
The cmd 1 calls a program and starts SVC level 1.
Step 4
The program called in Step 3 calls a program, starting SVC level 2.
Step 5
The program called in Step 4 calls a program, starting SVC level 3.
Step 6
End-of-SVC level 3 cycle, CMS reclaims resources.
Step 7
End-of-SVC level 2 cycle, CMS reclaims resources.
Step 8
Program at SVC level 1 calls another program.
Step 9
End-of-SVC level 2 cycle, CMS reclaims resources.
Step 10
End-of-SVC level 1 cycle, CMS reclaims resources.
Step 11
End command cycle for cmd 1. If CMS does not reclaim resources at end-of-SVC, it reclaims them at end-of-command.
Step 12
A new command is issued, cmd 2.
Step 13
A program is called by cmd 2.
Step 14
End-of-SVC level 1 cycle.
Step 15
End command cycle for cmd 2.
Step 16
Logging off ends the VM session. All resources associated with the virtual machine are released.
Figure 1. CMS Boundary Relationships
The figure is described in the surrounding text.
1 If you are from an MVS background, a VM session (LOGON to LOGOFF) is comparable to an MVS JOB, a CMS command cycle is comparable to an MVS JOB STEP, and a CMS SVC level is comparable to an MVS task or RB level.