Handling an out-of-storage condition in C, C++, COBOL, or PL/I
You can use the Language Environment condition handling
services to resolve an out-of-storage condition in your application. In the user-written condition
handler examples that follow, CEEGTST and CEECZST are used to get and reallocate heap storage.
CEEMRCR is also used to handle an out-of-storage condition in a user subroutine, and allow the
subroutine to be invoked again. For the user code that corresponds to this scenario, see:
- The examples in C/C++ examples using CEEHDLR, CEEGTST, CEECZST, and CEEMRCR for C or C++
- The examples in COBOL examples using CEEHDLR, CEEGTST, CEECZST, and CEEMRCR for COBOL
- The examples in PL/I examples using CEEHDLR, CEEGTST, CEECZST, and CEEMRCR for PL/I
- The out-of-storage condition arises in your subroutine, and Language Environment gives control to the user-written condition handler you have registered through CEEHDLR for the out-of-storage condition.
- The condition handler detects the out-of-storage condition and calls CEEMRCR to set the resume cursor to resume execution at the return address of your subroutine call.
- On return from the user condition handler, your main program regains control as if your subroutine has actually run.
- The main program tests a completion indicator and discovers that the subroutine did not actually complete.
- Your program then recognizes that it has been invoked with insufficient storage for maximum efficiency, and frees some previously allocated storage.
- The subroutine is invoked a second time and completes successfully.
See z/OS Language Environment Programming Reference for the syntax of all Language Environment condition handling services.