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



Larry Ducie wrote:
> ...
> As far as I'm aware, I only need to free objects created directly by the RPG
> program. I assume that all objects created internally within java will be
> garbage collected automatically once they are eligible (no non-circular
> references). As it stands, I am freeing all objects created by RPG-to-Java
> calls: I would class (no pun intended) a java object to be deemed created
> via a RPG-to-Java call as any object returned to my RPG program from a *JAVA
> procedure call. I would assume it is simply this reference that is being
> freed - not the object itself (as it could be referenced by another object
> within java).

That's all correct.  But rather than thinking of objects being "created"
by RPG, just think of RPG getting references to them.  Say you have a
Java
class that has a String object, and you have a method that returns the
String.
If you call that method twice from RPG, your RPG program will have two
references
to the String object, even though the calls didn't actually create any
objects
at all, since the String already existed before the calls.

> ...
> I'm going to look into creating a custom class that I simply instantiate via
> a RPG-to-Java call - I'll get this to create the transformer and
> StreamResult objects. I can then simply create a method that takes a byte
> array, and I'll create the StreamSource object within java. That way I'll
> only have one object referenced within my RPG program - my custom class.
> This object will never be cleaned up as long as the job runs. This should
> run quicker (I think).
> 

Larry, that sounds like a good idea to use a custom Java method to do
most of the Java code.  There is a fair amount of overhead in making a
JNI call.  (It's an similar situation to doing several commmands using
QCMDEXC vs calling a custom CL procedure.)

Have you tried freeing your objects in groups rather than one at a
time?  http://faq.midrange.com/data/cache/282.html
This is mentioned in the V5R3 version of the RPG programmer guide, but
not the V5R2 version.  Freeing them in groups should be quicker than
doing them one at a time, and also it's easier and more reliable than
keep tracking of every single reference.


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.