IBM User Guide for Java V7 on Windows > IBM SDK for Java > The Java Native Interface (JNI) > Copying and pinning
Using the isCopy flag
The JNI Get<Type> functions specify a pass-by-reference output parameter (jboolean *isCopy) that allows the caller to determine whether a given JNI call is returning the address of a copy or the address of the pinned object in the heap.
The Get<Type> and Release<Type> functions come in pairs:
- GetStringChars and ReleaseStringChars
- GetStringCritical and ReleaseStringCritical
- GetStringUTFChars and ReleaseStringUTFChars
- Get<PrimitiveType>ArrayElements and Release<PrimitiveType>ArrayElements
- GetPrimitiveArrayCritical and ReleasePrimitiveArrayCritical
If you pass a non-null address as the isCopy parameter, the JNI function sets the jboolean value at that address to JNI_TRUE if the address returned is the address of a copy of the array elements and JNI_FALSE if the address points directly into the pinned object in the heap.
Except for the critical functions, the IBM JVM always returns a copy. Copying eases the burden on the GC, because pinned objects cannot be compacted and complicate defragmentation.
To avoid leaks, you must:
- Manage the copy memory yourself using the Get<Type>Region and Set<Type>Region functions.
- Ensure that you free copies made by a Get<Type> function by calling the corresponding Release<Type> function when the copy is no longer needed.
Parent: Copying and pinning
Error 404 - Not Found Error 404 - Not Found
The document you are looking for may have been removed or re-named. Please contact the web site owner for further assistance.