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



Thanks Barbara. I downloaded the rpgjnilib save file and I will try to get that uploaded so that I can use the service program.

Dean

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Barbara Morris
Sent: Thursday, September 20, 2012 7:03 PM
To: rpg400-l@xxxxxxxxxxxx
Subject: Re: Calling Java from RPG take 2

On 2012/9/20 2:45 PM, Dean Eshleman wrote:
...
Do I need to worry about garbage collection if the process is called
multiple times within a job or is that handled for me? From what I
understand, a new string object would be created each time the
program is called. Should I set on LR each time it is called or
doesn't that make any difference other than from a performance
standpoint?


Yes, you do need to worry about garbage collection - nothing is handled
for you. Setting on LR will have no effect at all on garbage collection.
RPG never frees any objects other than the ones it creates itself to
call the Java methods, so any objects that Java can't free during
garbage-collection will remain until your job ends.

It's not just objects that you explicitly create that you have to worry
about. It's any _references_ to objects. You don't actually deal with
the objects themselves in your RPG programs; you deal with object
references, similar in concept to pointers. When Java has passed you an
object reference, even to an object that already existed, it remembers
that you have that reference, and it will never free that object, even
after all other Java processing was done with it.

So in your code, you explicitly create one String object with the
makeString call, and you also get an object reference to the returned
String object.

But it's pretty easy to handle once you get the JNI wrapper service
program set up (you could use the one from the Cafe, and I think Scott
Klement makes one available). Call beginObjGroup() at the beginning of
where you will be creating objects that you won't need later, and then
call endObjGroup() to tell Java that all the objects created the
beginObjGroup() are now available for garbage collection.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.