Occurs Depending Memory Use



Hi Everyone:

I work in a very large IBM z990 shop developing and suppporting COBOL/CICS
applications. A colleague approached me last week with an interesting
question on memory allocation and memory use in employing an OCCURS
DEPENDING ON clause versus an OCCURS (integer) TIMES clause.

If I define a table with a static clause, I know that memory allocation and
use will be 2,000 bytes. As follows...

01 WS-FILLER.
05 BASE-TABLE-1 OCCURS 100 TIMES.
10 BT-1-FIRST PIC X(10).
10 BT-1-SECOND PIC X(10).

If I define a second table with an OCCURS DEPENDING ON clause I had be
taught (and never before questioned) that memory allocation was dynamic.
The memory used would be only that which corresponds to the size of one
occurrence times the value of the depending on variable. In the example
below, at the start of execution I would expect the size of the table to be
20 bytes and only the maximum size to be static at 2,000 bytes.

05 BASE-TABLE-2 OCCURS 1 TO 100 TIMES DEPENDING ON MY-VAR.
10 BT-2-FIRST PIC X(10).
10 BT-2-SECOND PIC X(10).

05 MY-VAR PIC 9(4) COMP VALUE +1.

Yet, when I look at the compiled SAR listing of a program employing both
clauses I see that the memory map of both tables allocates 2,000 bytes.
Furthermore, when I step through the program I observe that the allocation
of BASE-TABLE-2 stays at 2,000 bytes regardless of the value of MY-VAR.
Additionally, when I put a CICS trace on the execution of a program using
BASE-TABLE-1 and then replace BASE-TABLE-1 by BASE-TABLE-2, keeping the
value of MY-VAR constant at 5, the total memory use reported in the trace is
identical for both program versions.

So, how much memory is actually used by an OCCURS DEPENDING ON clause? What
exactly is the difference between using OCCURS and OCCURS DEPENDING ON? If
there's no real savings in memory, then what's the point?

Any help provided will be greatly appreciated. Thanks.


.



Relevant Pages

  • Re: Occurs Depending Memory Use
    ... IBM supports NON-Standard ODO's (Occurs Depending On) where they are either ... > question on memory allocation and memory use in employing an OCCURS ... > DEPENDING ON clause versus an OCCURS TIMES clause. ...
    (comp.lang.cobol)
  • Re: Occurs Depending Memory Use
    ... A colleague approached me last week with an interesting question on memory allocation and memory use in employing an OCCURS DEPENDING ON clause versus an OCCURS TIMES clause. ...
    (comp.lang.cobol)
  • Re: Occurs Depending Memory Use
    ... >question on memory allocation and memory use in employing an OCCURS ... >DEPENDING ON clause versus an OCCURS TIMES clause. ... how much memory is actually used by an OCCURS DEPENDING ON clause? ...
    (comp.lang.cobol)
  • Re: allocating memory.
    ... So what would be the ASM equivalent of new memory ... Memory allocation is primarily an OS responsibility, ... OSes are almost certainly responsible for memory ...
    (alt.lang.asm)
  • Re: Doubts on Defining and declaring variables
    ... 1.Dim iage ... and allocate memory for each of them ... My understanding:-Still No memory allocation done at this ... Now since string is assigned to iage,So will ...
    (microsoft.public.scripting.vbscript)