Chapter Contents |
Previous |
Next |
Command Directory |
sto{rage}
storage
[heap|stack]
[check|report] [file|term] [narrow|wide]
storage
command prints an analysis of the program's use of both heap and stack storage. Heap storage is storage allocated by the
malloc
and
calloc
functions. Once allocated, this type of storage
remains allocated until it is freed. Stack storage is
storage used for automatic variables and register save areas. This storage
is allocated when a function is entered and is freed when the function returns.
The storage
command is
executed by the same subsystem as that used when the run-time
=storage
option is used.
storage
attempts
to predict storage-related user abends and to indicate the problem area.
storage
command.
Heap storage
: Heap
storage is allocated by the
malloc
and
calloc
functions. Both
functions interface to a routine called the heap manager to allocate storage.
The heap manager creates control information for the allocated storage block
and formats the storage block so that overlays (that is, information written
outside the boundaries of the storage block) can be detected. When an overlay
is detected (either when the storage is freed or when the program terminates),
the heap manager issues a user ABEND. This alerts the programmer to storage
overlays.
p = malloc(10);
p = malloc(300);
xxxxHEAPzzzzzzzzzzzzzzzzHEAPxxxx
In the original 16-byte block,
x
is a byte of control information and
z
is a byte.
xxxxFREEzzzzzzzzzzzzzzzzFREExxxx
Stack storage
:
Stack storage is storage that is allocated automatically for
auto
variables, register save areas, and other temporary use by a function. Normally,
stack storage is allocated from the stack when a function is called and is
returned to the stack when the function returns. However, if the stack overflows
(that is, runs out of available storage), the stack manager is called to allocate
another block of storage for the stack.
Validation
: As
the stack manager operates, the tract markers, save area chains, and the stack
control information are checked for consistency. If an overlay is detected
for example, caused by storing outside the boundaries of an
auto
array the stack manager issues a user ABEND.
storage
command in an
uncorrupted situation.
CDEBUG: storage
At SUB1(PGM1) entry ------ SIZE: FREE/USED SIZE: FREE/USED SIZE: FREE/USED SIZE: FREE/USED 24: 0/116 32: 0/118 40: 0/18 48: 0/69 56: 0/10 64: 0/7 72: 0/59 80: 0/10 88: 0/9 96: 0/4 104: 0/3 120: 0/2 144: 0/5 152: 0/1 160: 0/1 280: 0/1 512: 1/0 792: 1/0 1152: 1/0 1472: 1/1 1792: 0/2 8192: 0/1 No corruptions found in heap. SIZE NUMBER SIZE NUMBER SIZE NUMBER SIZE NUMBER SIZE NUMBER 152: 1 168: 1 208: 1 248: 1 256: 1 296: 2 672: 1 Total unused space in stack (bytes): 1768 No corruptions found in stack.
Line 1 shows the current function name and section name.
At SUB1(PGM1) entry ------
The current hook is entry to the function.
24: 0/116
512: 1/0
The large number of 24- and 32-byte blocks (representing
allocations of 1 to 8 bytes and 9 to 16 bytes, respectively) indicates that
this program can benefit from memory pooling via
pool
and its related functions.
No corruptions found in heap.
296: 2
The next example shows the output from storage
when a heap storage block is overlaid.
CDEBUG: } storage check heap
At SUB1(PGM1) 2 00005A LSCD622 Block (size: 00000078 (120)) at address 00007F20 has been overwritten. Header Address: 00007F20 Trailer Address: 00007F90 00007F20 00000078 C8C5C1D7 FCFCFCFC FCFCFCFC *....HEAP........* 00007F30 FCFCFCFC FCFCFCFC FCFCFCFC FCFCFCFC *................* . . . 00007F50 FCFCFCFC FCFCFCFC FCFCFCFC FCFCFCFC *................* 00007F60 TO 00007F90 SAME AS ABOVE ................. 00007F90 C7C5C1D7 00008310 00000078 FFFFFFFF *GEAP..c.........*
LSCD622 Block (size: 00000078 (120)) at address 00007F20 has been overwritten. Header Address: 00007F20 Trailer Address: 00007F90
The next example shows the output produced by storage
when it detects a stack overlay.
CDEBUG: storage check stack
At SUB1(PGM1) 2 00005A LSCD612 Auto storage control block has been overwritten at 00005FB5. 00005F98 00000FE0 00005FA8 00000000 40C1E2E3 *......^y.... AST* 00005FA8 0000C6E8 00000000 00000000=>00000000 *..FY............*
In this example, storage
analysis is limited to stack storage by use of the stack
option.
PROFILE | no |
configuration file | no |
Source window prefix | none |
storage
command is not affected by changes in scope.
Successful: 0 | |
Unsuccessful: 1 |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.