Occurs Depending Memory Use
- From: "Kevin Solomon" <kjsolo@xxxxxxxxxx>
- Date: Mon, 23 May 2005 11:54:08 -0400
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.
.
- Follow-Ups:
- Re: Occurs Depending Memory Use
- From: William M. Klein
- Re: Occurs Depending Memory Use
- From: Richard Maher
- Re: Occurs Depending Memory Use
- From: CG
- Re: Occurs Depending Memory Use
- From: HeyBub
- Re: Occurs Depending Memory Use
- From: Richard
- Re: Occurs Depending Memory Use
- From: Frederico Fonseca
- Re: Occurs Depending Memory Use
- From: Michael Mattias
- Re: Occurs Depending Memory Use
- Prev by Date: Money Movers Inc. project
- Next by Date: Re: Occurs Depending Memory Use
- Previous by thread: Money Movers Inc. project
- Next by thread: Re: Occurs Depending Memory Use
- Index(es):
Relevant Pages
|
|