|
-----Original Message-----make
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-
bounces@xxxxxxxxxxxx] On Behalf Of Aaron Bartell
Sent: donderdag 19 juni 2008 14:13
To: RPG programming on the AS400 / iSeries
Subject: Re: Is RPG 'DEAD"
Just wanted to provide some input on the garbage collection and
OutOfMemoryError stuff you brought up Corr.
I wrote an entire Java application that ran on a Canon
copier/scanner/fax
machine (one of those with the big LCD touch screens) and it most
definitely
had the potential to run out of memory (to the point where I could
it"flow"
happen almost at will). Here is a section of code for how I trapped
memory
errors and *attempted* to free garbage. You should note that reading
Suns
garbage collection documentation is required to really understand what
is
going on. For example, the below System.gc() didn't always free up as
much
memory as I expected it to based on the document images I was
processing.
Anyways, take it for what it's worth...
try {
if (garbageCollect)
System.gc();
garbageCollect = !garbageCollect;
byte[] newCopy = new byte[oar.data.length];
System.arraycopy(oar.data, 0, newCopy, 0,
oar.data.length);
outStream.write(newCopy);
outStream.flush();
} catch (IOException e) {
Log.out(Log.getStackTrace(e));
} catch (OutOfMemoryError e) {
Log.out("!!!!!!!!!!!!!!!!!!Out Of MEMORY
ERROR!!!!!!!!!!!!!!!!");
Log.out(Log.getStackTrace(e));
ignoreRemainingImages = true;
if (currentJobId > 0)
Device.cancelJob(currentJobId);
readEnd();
UICommand.imageTransferError("ERR002", "Page " +
currentPage
+ " exceeded maximum image size.");
return false;
}
BTW, programming for hardware is pretty fun, but WAY different than
what I
am normally used to, but still quite fun once you figure out the
ofa
setting up and tearing down communications.
Aaron Bartell
http://mowyourlawn.com
On Thu, Jun 19, 2008 at 1:23 AM, Takken, Cor <cor.takken@xxxxxxxxxx>
wrote:
It has been some time since I ever read such an entertaining (andlong)
thread. I will react only once and then lean back again and enjoythis
thread.in
First of all, I agree with all of you who have suggested that this
'consultant' should be asked to either name the IBM-guys and come up
with documents supporting this bold statement or resign his job (and
then climb some high mountains just to repent). RPG is not dead (or
alternatively: as dead as COBOL), and neither is Java or C#. All
languages have their purpose and right application, RPG is not for
high-end graphical applications and Java or C# have their strengths
other fields.
Now for some other things:
Java is better because it prevents memory-leaks (or words to that
extent).
Java as a language is not better. The language Java has no thing as
certaingarbage collector, and it does not prevent memory-leaks. The virtualinterfaces
machine which processes the Java code (or the intermediate compiled
bytecode) needs to implements a few interfaces. Implementing
means that you need to accept calls to certain functions with
representparameters, however nowhere in the documentation of Sun does it sayHOW
you need to implement these calls. I would even put it a bitstronger:
the Java documentation explicitly states that there is absolutely noanything
guarantee that calls to the garbage collection will guarantee
to be cleaned up. Cleaning up after badly written programs is theup...
responsibility of the JVM, but if the JVM decides never to clean
well then nothing is cleaned up, and at some point even the JVM willrun
out of memory and there is no try catch finally in the world thatwill
catch this because no program will run. Is java then better? I wouldcode
argue that it is not (but I will stand corrected) since there is no
that will allow me to explicitly remove objects (it allows me to useto
"new " to create objects, but is there a "old" or "cleanup" function
kill created objects?).
Classes are comparable to modules or service programs
RPG IV is not an object oriented language, Java is. Classes
comparedrunnable code which can only be used once instantiated as an object
(barred static methods), modules and service programs can be
toof
static (so class-level) methods. Classes are abstract descriptions
isobjects, objects are instantiations of classes and represent a classin
a certain state which can behave in a predescribed way (the code inthe
class) as is fit for that state. A module is not a class, a module
afrom
stream of code which can be called from the outside to perform somethere
functionality and that is it. A module is always a single thing,
is no way for an application to instantiate the same module in morethan
one instantiation and use them next to each other or simultaneously.The
whole concept of RPG does not even allow this and while I appreciatethat
that there are ways to simulate such behaviour (e.g. copy the same
module to different locations or by renaming the compiled object)
would still be a simulation and not have the same flexibility asobject
instantiation. The whole programming concept of RPG is different
C++,Object Oriented (or close to Object Oriented) languages as Java,
ofC#, etc. You can't compare the two except on the bare line to linecode
basis (comparing if-statements etc.).
And again: this consultant should either produce the hard evidence
the demise of RPG or forever hold his peace.--
Kind regards,
Cor
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing
list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.
As an Amazon Associate we earn from qualifying purchases.
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.