× 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.



>What is IIRC?

There's a FAQ entry on common acronyms at http://faq.midrange.com

>With an array everything is in memory, from
>what I understand and correct me if I am wrong,

Unless your memory pool is outlandishly large and you have no competition
for memory at all, you cannot guarantee that all elements of an array are in
memory.  Some may be paged out, especially in a large array.  Contrariwise,
if you have such an outlandish amount of memory, the entire disk file may
well be paged in and you don't have to "go out to disk" to get the records.

Realistically, there's a middle ground where you just can't make predictions
about what is currently memory-resident and what is not.  The way it works
is that OS/400 will allow other processes to gradually take memory that your
program is not using.  Say you have

init subr
read subr
calc subr
write subr
error subr

When the program is loaded, ALL the subroutines are loaded and their storage
initialised.  As the program runs, the system sees that the memory used by
subr init hasn't been used for a long time, so the system gives it away.
The same thing happens with the storage taken up by error (our code doesn't
have errors, does it?)  So all that's left _in memory_ are read, calc and
write (and associated variables.)

But the system doesn't stop at the subroutine level; it goes to the memory
page level.  If you have a large array that is used by all three subroutines
(look, I'm on topic!) but only has 5 elements populated, every time you
reference one of those elements, you reset the memory page life timer.  The
system knows that this memory page is in use and will try hard not to swap
it out.  If elements 5000-32000 are never referred to, the pages they are in
will be given away, even though element 1 is referenced every cycle.  Do
note that those pages will have to be swapped back in if I do a Z-ADD 0
ARRAY, or any other operation that involves the entire array.

Turn that around and imagine reading a file repeatedly by key.  If you read
the same 5 records over and over, the memory pages they live in will stay in
memory because they are referred to often.  Despite the fact that I am doing
a CHAIN, no disk activity is taking place; the record is already in memory
because it is part of the working set for this process.  Of course if you
randomly access records, the oldest page (record) gets given away.

That's why I tell people not to think of OS/400 as a PC with an accent.  A
PC program makes certain assumptions about memory consumption that simply do
not apply to OS/400 programs.  Trying to make RPG act like VB is not a good
way to approach programming on OS/400.  This is my opinion of course, but I
challenge people to model the different behaviours on their machine and
capture statistics with PEX on a production system before making a decision
on the benefits of one methodology over another.

  --buck


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.