IBM User Guide for Java V7 on Windows > IBM SDK for Java > The Java Native Interface (JNI)
The JNI and the Garbage Collector
This description explains how the JNI implementation ensures that objects can be reached by the Garbage Collector (GC).
For general information about the IBM GC, see The collector and the allocator.
To collect unreachable objects, the GC must know when Java™ objects are referenced by native code. The JNI implementation uses "root sets" to ensure that objects can be reached. A root set is a set of direct, typically relocatable, object references that are traceable by the GC.
There are several types of root set. The union of all root sets provides the starting set of objects for a GC mark phase. Beginning with this starting set, the GC traverses the entire object reference graph. Anything that remains unmarked is unreachable garbage. (This description is an over-simplification when reachability and weak references are considered. See Global garbage collection and the JVM specification.)
- Overview of JNI object references
The implementation details of how the GC finds a JNI object reference are not detailed in the JNI specification. Instead, the JNI specifies a required behavior that is both reliable and predictable.- JNI transitions
To understand JNI local reference management and the GC, you must understand the context of a running thread attached to the JVM. Every thread has a runtime stack that includes a frame for each method call. From a GC perspective, every stack establishes a thread-specific "root set" including the union of all JNI local references in the stack.
Parent: The Java Native Interface (JNI)
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.