View previous topic :: View next topic
|
Author |
Message |
bantu2405
New User
Joined: 03 Nov 2009 Posts: 2 Location: Pune
|
|
|
|
Hi, Could you please tell me is it necessary to use GETMAIN in all the CICS programs, as it is used to allocate memory, but there are many CICS program in my system which hardly uses GETMAIN? I want to know exactly when should one use the GETMAIN?
Thanks a lot for you help |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
Everybody has his own reason to obtain storage by GETMAIN. I always
use it for getting working storage and make it addressable by DSECT's.
For instance loading a PDS directory in storage, and then processing it
to read all members.
Or to generate vsam control blocks, dcb's, system control blocks defined
only in DSECT format.
In short there are numerous reasons to use it. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
I want to know exactly when should one use the GETMAIN? |
Sounds like a solution in search of a requirement. . .
Suggest you look at other code on the system that uses GETMAIN and see why/when this is typically used in your environment. |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
I forgot to mention that GETMAIN is also very often used in refreshable or re-enterable or reusable programs. |
|
Back to top |
|
|
Debabrata Pruseth
New User
Joined: 11 Dec 2008 Posts: 59 Location: Pune , India
|
|
|
|
Hi Bantu
The most practical scenario where you come to know the importance of using GETMAIN is when you don't use it properly and the working storage variables point to wrong memory address and pick up junk values . In this case your code will abend with ASRA and the whole lot of it and you will be scratching your head from where these junk values are coming from .
So start using GETMAIN wherever it is required , it is a good practice. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Since this is the CICS forum, I will stay within the scope of CICS. And as such, will not get into a lot of detail; I am not going to elaborate on the background issues/whys/wherefores - that is available on the net and in manuals.
1. A GETMAIN is a request from the ops-system for additional storage for a task. After the issuance of a FREEMAIN, the storage is nolonger assigned to the TASK. Thus, a reduction of resources for a task - very important in CICS environment.
2. Often you don't know how much extra storage you need for an internal cobol table, or simply passing data to another module within the task. If the GETMAINing module was compiled with the maximum amount of potential storage requirements within Working-Storage, then the module would be larger than necessary.
(some situations would require x amount of storage, some y)
Acquiring the necessary amount of storage at runtime (via GETMAIN) means that the load module is smaller, thus requiring less CICS resources to load. We are talking about CICS - which is online/on demand - thus reducing the likelihood of the module not being loaded (thus task not executing) or preventing another task from be initiated due to lack of available storage -
(READ: because some idiot wrote a 4 meg module that runs 1000 times a day and hogs all the resources.)
3. Because many coders are too lazy to learn anything new (GETMAIN) and due to the fact that most programmers are only concerned with their own program - and not the impact on the system as a whole (using more storage than necessary) - they don't understand that the assignment of storage via the GETMAIN command - and the freeing of it with the FREEMAIN command - don't really take that much extra time. When properly used
(READ: have a formula in the module to determine how much memory to request during runtime- sometime repeated requests are necessary)
the impact of the module on the system as a whole does not stand-out; where as a memory hog does - everytime.
hopefully Bill Boyle will chime in with his expertise. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Quote: |
hopefully Bill Boyle will chime in with his expertise.
|
or correct any of my incorrect statements. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
That's Bill O'Boyle
My apologies Bill.
my 8000 year old brain suffers from long term usage. |
|
Back to top |
|
|
|