System abend

S804: Not enough virtual storage (GETMAIN)

An S804 abend means a program asked z/OS for virtual storage with a GETMAIN request and there wasn't enough room, so the system ended the step. Usually the job's region was too small for what the program needed.

Also written as 804, abend 804, S804 abend, S804-10, 804-10, system abend 804, GETMAIN failed.

What it means

Programs get their working storage from z/OS while they run. They ask with a GETMAIN or STORAGE request, and the system takes the space from the private area of the job's address space, up to the limit set by REGION. If there isn't room, and the program didn't say it could manage without the storage, the system ends the step.

Which code you get depends on the form of the request, not on what went wrong. S804 comes from the EU, LU and VU forms of GETMAIN. S80A comes from the R form, and S878 from the newer register forms and STORAGE OBTAIN. In practice the three mean the same thing and have the same fixes.

Message IEA705I appears with the code and a reason, such as 804-10. The reason names the storage area that ran short. Reason 10 is the one most jobs hit. It means the private area of your address space had no room left, and that is the area REGION controls.

Common causes

  • REGION is too small for the program, often after the program grew with bigger tables, new copybooks or more files open.
  • The program builds a table in storage whose size depends on the input, and today's input was bigger.
  • A storage leak. The program gets storage again and again, for example inside a loop, and never frees it.
  • The program or its data has to live below the 16 MB line, for example an AMODE 24 program or a COBOL program compiled with DATA(24). That area is small and runs out even when there is plenty of storage above the line.
  • Your site's IEFUSI exit or SMFLIMxx parmlib member gave the step less storage than the REGION you coded.

How to find the problem

  1. Find IEA705I in the job log. Note the reason code and the size of the request. A huge request, such as hundreds of megabytes, points to a bad length value from a program bug rather than a real need.
  2. Check REGION on the EXEC statement and on the JOB statement. REGION on the JOB statement overrides the EXEC value for every step.
  3. Read the step end message IEF032I. VIRT and EXT show the most user storage the step used below and above the 16 MB line. If VIRT is close to the region below the line, that is the area that ran out.
  4. For a Language Environment program, rerun with the runtime option RPTSTG(ON) to get a report of its heap and stack use.
  5. If the step fails at a different point each time with the same input, suspect a leak.

How to fix it

  • Raise REGION on the EXEC statement, for example REGION=64M, or on the JOB statement if your standards say so. REGION=0M asks for all the storage your site allows.
  • Move storage above the line. Compile COBOL with DATA(31), link the program AMODE 31, and use the Language Environment options ALL31(ON) and HEAP and STACK with ANYWHERE.
  • Fix any leak so the program frees what it gets.
  • If the storage you get is less than you asked for, ask your system programmer about the IEFUSI exit or SMFLIMxx limits.

What it looks like

IEA705I ERROR DURING GETMAIN SYS CODE = 804-10  INVLOAD1 STEP010
IEF450I INVLOAD1 STEP010 - ABEND=S804 U0000 REASON=00000010
IEF032I STEP/STEP010 /STOP 2026285.0912
        CPU:     0 HR  00 MIN  01.07 SEC    SRB:     0 HR  00 MIN  00.02 SEC
        VIRT:  8180K  SYS:   312K  EXT:        0K  SYS:    10840K

Questions

What is the difference between S804, S80A and S878?

They differ only in the kind of storage request the program made. S804 comes from the EU, LU and VU forms of GETMAIN, S80A from the R form, and S878 from the newer register forms and STORAGE OBTAIN. The causes and fixes are the same, and the reason code matters more than which of the three you got.

Is REGION=0M a good idea?

It asks for all the private storage your site allows. Some sites restrict it, and it only delays a failure caused by a leak, so check your standards first.

Why didn't a bigger REGION fix it?

Either the program is leaking storage, or it needs storage below the 16 MB line, which REGION can't enlarge past what the system has free there. Your site's limits may also be capping the REGION you asked for.