MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

how does a program alocate memory?

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
jctgf
Beginner


Joined: 05 Nov 2006
Posts: 89
Topics: 36

PostPosted: Fri Feb 27, 2009 9:31 pm    Post subject: how does a program alocate memory? Reply with quote

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
View user's profile Send private message Send e-mail
Terry_Heinze
Supermod


Joined: 31 May 2004
Posts: 391
Topics: 4
Location: Richfield, MN, USA

PostPosted: Fri Feb 27, 2009 9:37 pm    Post subject: Reply with quote

When the program is loaded since the array (table) is part of the load module and determined at compile time.
_________________
....Terry
Back to top
View user's profile Send private message Send e-mail
jctgf
Beginner


Joined: 05 Nov 2006
Posts: 89
Topics: 36

PostPosted: Sat Feb 28, 2009 7:37 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Nic Clouston
Advanced


Joined: 01 Feb 2007
Posts: 1075
Topics: 7
Location: At Home

PostPosted: Sat Feb 28, 2009 10:05 am    Post subject: Reply with quote

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
View user's profile Send private message
semigeezer
Supermod


Joined: 03 Jan 2003
Posts: 1014
Topics: 13
Location: Atlantis

PostPosted: Sat Feb 28, 2009 3:23 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group