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



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 make it
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 "flow" of
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 (and long)
thread. I will react only once and then lean back again and enjoy this
thread.

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 in
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 a
garbage collector, and it does not prevent memory-leaks. The virtual
machine which processes the Java code (or the intermediate compiled
bytecode) needs to implements a few interfaces. Implementing interfaces
means that you need to accept calls to certain functions with certain
parameters, however nowhere in the documentation of Sun does it say HOW
you need to implement these calls. I would even put it a bit stronger:
the Java documentation explicitly states that there is absolutely no
guarantee that calls to the garbage collection will guarantee anything
to be cleaned up. Cleaning up after badly written programs is the
responsibility of the JVM, but if the JVM decides never to clean up...
well then nothing is cleaned up, and at some point even the JVM will run
out of memory and there is no try catch finally in the world that will
catch this because no program will run. Is java then better? I would
argue that it is not (but I will stand corrected) since there is no code
that will allow me to explicitly remove objects (it allows me to use
"new " to create objects, but is there a "old" or "cleanup" function to
kill created objects?).

Classes are comparable to modules or service programs
RPG IV is not an object oriented language, Java is. Classes represent
runnable code which can only be used once instantiated as an object
(barred static methods), modules and service programs can be compared to
static (so class-level) methods. Classes are abstract descriptions of
objects, objects are instantiations of classes and represent a class in
a certain state which can behave in a predescribed way (the code in the
class) as is fit for that state. A module is not a class, a module is a
stream of code which can be called from the outside to perform some
functionality and that is it. A module is always a single thing, there
is no way for an application to instantiate the same module in more than
one instantiation and use them next to each other or simultaneously. The
whole concept of RPG does not even allow this and while I appreciate
that there are ways to simulate such behaviour (e.g. copy the same
module to different locations or by renaming the compiled object) that
would still be a simulation and not have the same flexibility as object
instantiation. The whole programming concept of RPG is different from
Object Oriented (or close to Object Oriented) languages as Java, C++,
C#, etc. You can't compare the two except on the bare line to line code
basis (comparing if-statements etc.).

And again: this consultant should either produce the hard evidence of
the demise of RPG or forever hold his peace.

Kind regards,

Cor



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

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.