If you have created a global reference, and you know that you no longer need this object, then you should tell Java™ that as far as you are concerned, the object can be destroyed when Java next performs its garbage collection. (The object will only be destroyed if there are no other global references to it, and if there are no other references within Java itself.) To tell Java that you no longer need the reference to the object, call the RPG wrapper procedure freeGlobalRef .
CALLP freeGlobalRef (JNIEnv_P : globalString);
Figure 1 contains sample source code for freeGlobalRef.
/*------------------------------------------------------*/
/* freeGlobalRef */
/*------------------------------------------------------*/
P freeGlobalRef...
P B EXPORT
D freeGlobalRef...
D PI
D env * VALUE
D globalRef O CLASS(*JAVA
D : 'java.lang.Object')
D VALUE
/free
jniEnv_P = env;
DeleteGlobalRef (env : globalRef);
/end-free
P freeGlobalRef...
P E