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



"Steffan, Otto (GE Consumer Finance)" wrote:
> ...
>         OUDESC = getBytes(getOudesc(jobject)) ; //  <<<< the issue concerns
> this line
> .....
> OUDESC is an output CHAR field declared in a display DDS source.
> What I am affraid of is if java or something else frees a temporary String
> object that getOudesc method creates and passes to getBytes method.
> Actually, it is not a problem in this testing programme, the snippets come
> from, but I am going to use these methods and the attested solutions in
> batch programmes in which they (and others) will be called on really large
> scale. I want  to avoid some memory problems in advance.
> ...

You are more likely to have problems with unfreed objects than with
inadvertently freed objects.  When Java passes an object reference to
native through JNI, it won't free the object until the native caller
frees it.  (Java keeps track of the number of references an object has,
and it won't free it until all the references are gone.)  You free
objects from your native code either one at a time using FreeLocalRef or
many at a time using PushLocalFrame and PopLocalFrame.
      for iRSRows = 0 to nRSRows - 1;  
        jobject = GetObjectArrayElement ( JNIEnv_P  : RSRows  : iRSRows
); <-- leak
        OUDESC = getBytes(getOudesc(jobject)); 

On the assignment to jobject here, you are losing the ability to
explicitly free the previous reference held by jobject.  If you code a
call to PushLocalFrame before your loop and to PopLocalFrame after your
loop, all the object references will be freed.  (This doesn't
necessarily mean the object itself will be freed, but at least you won't
be preventing Java's garbage collection from freeing it if when it's no
longer needed at all.)

Here are some RPG wrappers for FreeLocalRef and the Push/Pop LocalFrame
functions.
http://faq.midrange.com/data/cache/282.html


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.