× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: RE: Static, Automatic and Heap Storage
  • From: watern@xxxxxxxxxxxxxx
  • Date: Wed, 1 Dec 1999 06:01:25 -0500



Alan,

Thanks for your explanation.

I think what you are calling static and automatic storage I have come
across in the past, in other languages, as global and local storage. If I
remember rightly, in Quickbasic you could declare variables as being either
global or local. I think the only reason that variables in a subprocedure
would be global would be if other parts of the program needed to know about
them.

>The term static storage means that the storage is allocated at the start
of
>a program or module.
.....
>Automatic storage is different. Automatic storage only exists inside of a
>sub-procedure and only for the life of the sub-procedure. When you call
that
>function, any storage, i.e. variables, required are allocated from the
>system heap, .....

Trying to make sense of my original thinking, I can see that if
sflsiz=sflpag, since the compiler would know exactly how much storage was
required for subfile fields it would be possible for the subfile data to be
accomodated in static storage. If sflsiz>sflpag, then automatic storage
would have to be used as the amount of space is not known until run-time.

I thought automatic storage was used where the amount of space required was
unknown at compilation time, but you seem to be saying it is also used
where the program/procedure uses the same amount of space, but does not
need to retain values between calls.

I had the idea that when a program is called in a job, it uses space in the
PAG for holding file i/o handles etc and variables contained in static
storage.  Since automatic storage would always be outside the PAG, there
would be an overhead associated to handling data there.  I may have this
completely wrong. I am sure that compilation listing used to give
information about static storage and automatic storage areas used by the
program object. (PSSA and PASA).

>This reason this all important is that languages like ILE RPG (C type
>languages) are very efficient at managing automatic storage and very
>inefficient at managing static storage.

I am very surpised at this. I would have expected that static storage would
always be more efficient to manage as the amount of space required never
changes for different invocations of the same program.

As a footnote, the dsppgm command will show you space size for both static
and automatic storage for OPM programs, but will only show static storage
size for ILE programs.

I'm not quite sure where I am going with this one, other than confusing
myself more. Sorry !

I didnt previously understand the similarity between static/automatic and
global/local variables, so thanks for explaining that.

Rgds,
Nigel


+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.