View previous topic :: View next topic |
Author |
Message |
jctgf Beginner
Joined: 05 Nov 2006 Posts: 89 Topics: 36
|
Posted: Fri Feb 27, 2009 9:31 pm Post subject: how does a program alocate memory? |
|
|
hi,
i'd like to know how a cobol subroutine allocates memory when it is invoked with the CALL command, please.
if i have a cobol subroutine with several arrays defined in the WS, is the memory needed for all those arrays allocated when the program is
loaded? or, are the arrays allocated as they are filled?
summing up, what does spend more memory?
a) a only program with array A (1 mg) and array B (2 mb);
b) two separate programs, each one containing one of the arrays mentioned in item (a);
thanks. |
|
Back to top |
|
 |
Terry_Heinze Supermod
Joined: 31 May 2004 Posts: 391 Topics: 4 Location: Richfield, MN, USA
|
Posted: Fri Feb 27, 2009 9:37 pm Post subject: |
|
|
When the program is loaded since the array (table) is part of the load module and determined at compile time. _________________ ....Terry |
|
Back to top |
|
 |
jctgf Beginner
Joined: 05 Nov 2006 Posts: 89 Topics: 36
|
Posted: Sat Feb 28, 2009 7:37 am Post subject: |
|
|
hello terry,
do you mean the memory allocation of all arrays will occur when the module is loaded, regardless the fact the array will be used or not?
do you think the program described in item A in my example will always spend more memory?
thanks. |
|
Back to top |
|
 |
Nic Clouston Advanced
Joined: 01 Feb 2007 Posts: 1075 Topics: 7 Location: At Home
|
Posted: Sat Feb 28, 2009 10:05 am Post subject: |
|
|
Unless the storage for the array is CONTROLLED (PL/1) then the storage required is part of the load module. The entire load module is loaded at program initiation time. _________________ Utility and Program control cards are NOT, repeat NOT, JCL. |
|
Back to top |
|
 |
semigeezer Supermod
Joined: 03 Jan 2003 Posts: 1014 Topics: 13 Location: Atlantis
|
Posted: Sat Feb 28, 2009 3:23 pm Post subject: |
|
|
If that is a problem, you can allocate storage as you go and create your own data structures but I suspect that in COBOL that is not done very often. It is probably fairly common in PL/I since PL/I makes using pointers completely trivial. I don't use either language more than a few times a decade, so I don't really know what is common or not. If you do allocate your own storage i the program, remember to free it before the program (or transaction or whatever unit is appropriate) ends. _________________ New members are encouraged to read the How To Ask Questions The Smart Way FAQ at http://www.catb.org/~esr/faqs/smart-questions.html. |
|
Back to top |
|
 |
|
|