• Home
    • View
    • Login
    This page
    • Normal
    • Export PDF
    • Page Information

    Loading...
  1. Dashboard
  2. Undefined Space
  3. Port: MacOSX
  4. ObjC Memory Management & Java

Page History

Versions Compared

Old Version 6

changes.mady.by.user Mike Swingler

Saved on Jun 09, 2011

compared with

New Version 7

changes.mady.by.user Mike Swingler

Saved on Jun 09, 2011

  • Previous Change: Difference between versions 5 and 6
  • Next Change: Difference between versions 7 and 8
  • View Page History

Key

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

...

As a rule, Java objects should own native objects in jlongs

  • 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
  • This keeps the number of JNI global refs HotSpot has to manage to a minimum
    • Java objects should not be pinned in the Java heap until some random native retain count lowers or the ObjC-GC decides to kick in
  • 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 problemsDo not let native objects hold onto Java objects in JNI global refs, or you can create a cycle across the Java and ObjC garbage collectors, and neither collector will realize that they can deallocate their respective objects

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

    ...

Overview
Content Tools
ThemeBuilder

Terms of Use
• License: GPLv2
• Privacy • Trademarks • Contact Us

Powered by a free Atlassian Confluence Open Source Project License granted to https://www.atlassian.com/software/views/opensource-community-additional-license-offer. Evaluate Confluence today.

  • Kolekti ThemeBuilder Powered by Atlassian Confluence 8.5.21
  • Kolekti ThemeBuilder printed.by.atlassian.confluence
  • Report a bug
  • Atlassian News
Atlassian
Kolekti ThemeBuilder EngineAtlassian Confluence
{"serverDuration": 238, "requestCorrelationId": "d958d25607728103"}