Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • This keeps the number of JNI global refs HotSpot has to manage to a minimum
    • Java objects are not pinned until some retain count lowers or the ObjC-GC runs
  • Java objects that own native objects have to concretely define the lifecycle of the native objects they hold
  • The jlong type is used because it is big enough to hold both 32 and 64-bit sized pointers
    • Use the jlong_to_ptr() and ptr_to_jlong() macros to correctly handle casting and avoid sign-extension problems

Native objects held by Java objects must have a "hard" CF-retain count of 1 before being passed up to Java

  • ObjC objects that are +alloc'd or -retained are not actually pinned in GC-mode unless they have been CFRetain()'d .
    • As a counterpoint, any CFRetain()'d ObjC object must be -released or -autoreleased for it's retain count to remain balanced in RR mode.
  • The ObjC garbage collector cannot see into the Java heap, and infer if any native objects are still "alive"