Rational Developer for System z
COBOL for Windows, Version 7.5, Programming Guide


Deleting, saving, and freeing local references

You can manually delete local references at any point within a method. Save local references only in object references that you define in the LOCAL-STORAGE SECTION of a method.

Use a SET statement to convert a local reference to a global reference if you want to save a reference in any of these data items:

Otherwise, an error occurs. These storage areas persist when a method returns; therefore a local reference is no longer valid.

In most cases you can rely on the automatic freeing of local references that occurs when a method returns. However, in some cases you should explicitly free a local reference within a method by using the JNI service DeleteLocalRef. Here are two situations where explicit freeing is appropriate:

Use the following callable services to manage local references and global references.

Table 57. JNI services for local and global references
Service Input arguments Return value Purpose
NewGlobalRef
  • The JNI environment pointer
  • A local or global object reference
The global reference, or NULL if the system is out of memory To create a new global reference to the object that the input object reference refers to
DeleteGlobalRef
  • The JNI environment pointer
  • A global object reference
None To delete a global reference to the object that the input object reference refers to
DeleteLocalRef
  • The JNI environment pointer
  • A local object reference
None To delete a local reference to the object that the input object reference refers to

related tasks
Accessing JNI services


Terms of use | Feedback

Copyright IBM Corporation 1996, 2008.
This information center is powered by Eclipse technology. (http://www.eclipse.org)