HEAP (Heap Analysis)

The HEAP command displays information about the heaps in use by a Pascal process. Before you can use the HEAP command, you must use the HEAPSTACK command to specify the target process stack.

Syntax

── HEAP ─┬────────────────────────────────────────────────────────┬────┤
         ├────────────────────┬─<heap pointer>─┬──────────────────┤
         └─ S ──<heap number>─┘                └─ FOR ─┬─<length>─┤
                                                       └─ SIZE ───┘

<heap pointer>

──<Pascal pointer>─┬───────────────────┬───────────────────────────────┤
                   └─ + ──<skip value>─┘

Explanation

The following text explains the meaning of each construct. The heap number, length, and skip value are hexadecimal numbers.

HEAP

Displays information about all the heaps in use by the process stack specified by the HEAPSTACK command.

S <heap number>

Specifies a separate heap that the heap pointer is applicable to. If the S <heap number> clause is not used, or if the heap number specified is 0, the nonseparate heap is displayed.

<heap pointer>

Causes the display to begin at the specified point in the heap.

For separate heaps, the heap pointer is a row index into the dope vector for the separate heap. For the nonseparate heap, the heap pointer is a word offset into the heap array.

If the skip value is included, it specifies an offset, in words, from the Pascal pointer. The display starts at the specified offset. The skip value cannot skip past the end of a separate heap entry or beyond the end of a nonseparate array row.

FOR <length> FOR SIZE

Specify the number of words to be displayed. If no FOR clause is included, a single word is displayed.

If the FOR <length> clause is used, then the length specifies the number of words to be displayed. The actual number of words displayed is the minimum of the length and the number of words remaining in the row after the heap pointer.

If the FOR SIZE clause is used, the structure of the heap determines the number of words displayed. For separate heaps, the size is the row size of the specified heap, minus any specified skip value. For the nonseparate heap, the size is the number of words in the heap page, minus any specified skip value.

Example 1

The following example shows the output from a simple HEAP command for a process stack that is using only the nonseparate heap:

INPUT: HEAP
NON SEPARATE HEAP ROWS 0 - 19 IN USE, TOP OF HEAP IS 196F1B
SYSTEM PAGE SIZE IS 100 (256) WORDS

Example 2

The remaining HEAP examples show the progressive analysis of a single process stack that uses multiple separate heaps. The following example shows the output from a simple HEAP command for this process:

INPUT: HEAP
A (10) SEPARATE HEAPS IN USE
# 1  22, TOP: 80, FREE HDR: 7E, MAX SIZE: FFFFF, 100 OF AB WORDS
# 2  23, TOP: 0, FREE HDR:-1, MAX SIZE: FFFFF,  ABSENT
# 3  24, TOP: 53, FREE HDR: -1, MAX SIZE: FFFFF, 100 OF 9 WORDS
# 4  25, TOP: 89, FREE HDR: 7A, MAX SIZE: FFFFF, 100 OF 6 WORDS
# 5  26, TOP: 2, FREE HDR: 1, MAX SIZE: FFFFF, 100 OF 2AAE WORDS
# 6  27, TOP: 30, FREE HDR: 2D, MAX SIZE: FFFFF, 100 OF 12 WORDS
# 7  28, TOP: 6F, FREE HDR: 3D, MAX SIZE: FFFFF, 100 OF C WORDS
# 8  29, TOP: 0, FREE HDR: -1, MAX SIZE: FFFFF,  ABSENT
# 9  2A, TOP: 5A, FREE HDR: -1, MAX SIZE: FFFFF, 100 OF 8A WORDS
# A  2B, TOP: 2, FREE HDR: 1, MAX SIZE: FFFFF, 100 OF 6 WORDS
SYSTEM PAGE SIZE IS 100 (256) WORDS

The following table explains the various elements in the previous example:

Element

Meaning

# xx

Heap number, 1 through nn

@ yy

Offset of descriptor from bottom-of-stack register (BOSR)

TOP:

Current top of heap marker

FREE:

Head of free list within heap. A value of -1 means the free list is empty.

MAX SIZE:

Maximum number of entries allowed in heap

ABSENT:

Heap not yet used

zz of aa WORDS

zz rows (entries) of size aa words each

Example 3

The following command attempts to display row 100 in separate heap 0:

INPUT: HEAP S 0 100
NON SEPARATE HEAP IS NOT AVAILABLE

Because separate heap 0 does not exist, DUMPANALYZER attempts to display word 100 of the nonseparate heap. Because a nonseparate heap does not exist for this process, DUMPANALYZER returns the error message shown.

Example 4

The following example shows the output from several commands that analyze separate heaps associated with the same process stack.

INPUT: MD STK 93E BOSR + 2B
000D5C73(00000000) 5 800010 0104A4
:READY
INPUT: MD VIA 104A4 FOR 100
000B32C4(00000000) 5 800000 610CCE 5 800000 6139E3 5 000000 600000 
000B32C7(00000003) 5 000000 600000 5 000000 600000 5 000000 600000
000B32CA(00000006) 5 000000 600000 THRU 000B33C3(000000FF)
:READY
INPUT: MD VIA 10CCE FOR 6
0022A538(00000000) 3 4EFC63 468848 3 000807 30E3EF 3 400000 000001 
0022A53B(00000003) 3 4EFC63 46D482 3 000803 90E3F0 0 C4C9E2 D7E9C4
:READY
INPUT: HEAP S A 0 FOR SIZE
0022A538(00000000) 3 4EFC63 468848 3 000807 30E3EF 3 400000 000001 
0022A53B(00000003) 3 4EFC63 46D482 3 000803 90E3F0 0 C4C9E2 D7E9C4
:READY
INPUT: MD VIA 139E3 FOR 6
000FD356(00000000) 3 4EFC63 796699 3 000807 30E3EF 3 000000 000000 
000FD359(00000003) 3 4EFC63 79A5B5 3 000803 90E3F0 0 C4C9E2 D7E9C4
:READY
INPUT: HEAP S A 1 FOR SIZE
000FD356(00000000) 3 4EFC63 796699 3 000807 30E3EF 3 000000 000000 
000FD359(00000003) 3 4EFC63 79A5B5 3 000803 90E3F0 0 C4C9E2 D7E9C4
:READY
INPUT: HEAP S 3 1 FOR SIZE
001EF936(00000000) 3 4EFC63 10C1FB 3 000808 91238C 0 35C5E6 7DC440
001EF939(00000003) 0 001300 011C04 0 0CF0F8 F0F0F0 0 C2F0F0
F0F2F9
001EF93C(00000006) 0 F2C5E6 7DC440 0 D5C5E6 7DC440 0 D5C5E6 7DC440
:READY
INPUT: HEAP S 3 1+2 FOR SIZE
001EF938(00000000) 0 35C5E6 7DC440 0 001300 011C04 0 0CF0F8 F0F0F0 
001EF93B(00000003) 0 C2F0F0 F0F2F9 0 F2C5E6 7DC440 0 D5C5E6 7DC440
001EF93E(00000006) 0 D5C5E6 7DC440
:READY
INPUT: HEAP S 3 1+2 FOR 3
001EF938(00000000) 0 35C5E6 7DC440 0 001300 011C04 0 0CF0F8 F0F0F0
:READY

The following table explains the results of the commands shown in Example 4.

Command

Result

MD STK 93E BOSR + 2B

Displays the stack cell containing the descriptor for heap A. The heap is identified by its offset of 2B; this offset appears in the output for the simple HEAP command shown previously. The simple HEAP command also shows that heap A can hold FFFFF entries, and that currently space for 100 rows of size 6 words has been allocated. The top of heap value is 2, indicating the next nonallocated row that can be used. The free header is 1, which means that the row at index 1 has been disposed and is in the free chain.

MD VIA 104A4 FOR 100

Displays the contents of the dope vector of the heap. The address of the dope vector, 104A4, was taken from the output of the previous command. It shows that only rows 0 and 1 have been used.

MD VIA 10CCE FOR 6

Displays the contents of row 0 of separate heap A. The address of the row descriptor, 10CCE, was derived from the first word of the dope vector for heap A.

Because the process was executing a Pascal program compiled with the HEAPDEBUG option set, several words of trace information appear at the start of the row; these are the tag 3 words. The following list explains their meanings, in order:

  • The first word is the timestamp of the NEW call that last returned the row for program use.

  • The second word is the return control word (RCW) where the NEW call was made.

  • The third word is the free list link. Note the free list link of -1.

  • The fourth word is the dispose timestamp.

  • The fifth word is the return control word (RCW) where the DISPOSE call was made.

The third, fourth, and fifth trace words appear only for rows that are disposed.

HEAP S A 0 FOR SIZE

Displays row 0 of separate heap A. This HEAP command displays the same information as the previous MD command, but is easier to use. That is, the HEAP command can be used without examining the heap descriptor and dope vector first.

MD VIA 139E3 FOR 6

Displays the contents of row 1 of separate heap A. The address of the row descriptor, 139E3, was derived from the second word of the dope vector for heap A. Like row 0, row 1 is disposed and includes five words of trace information in the order described for row 0. Note the free list link of 0.

HEAP S A 1 FOR SIZE

Displays row 1 of separate heap A. This area is the same as that displayed by the previous MD command.

HEAP S 3 1 FOR SIZE

Displays the row at index 1 in heap number 3, which is a nondisposed area. The amount of memory displayed is the size of the row; that is, the size of the record type that is in this heap.

As discussed previously, the row contains trace information in the tag 3 words. Because the row is not disposed, only the first two tag 3 words appear: the timestamp of the last NEW call and the RCW for the NEW call.

HEAP S 3 1+2 FOR SIZE

Displays the row at index 1 in heap number 3. The first two words, storing the trace information, are omitted. The amount of memory displayed is equal to the size of the row minus two, for the words that are omitted.

HEAP S 3 1+2 FOR 3

Displays the same information as the previous command, except that the output is limited to 3 words.