Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-1227220

fp.bugs 2203: Notification to native code when it can free memory.

XMLWordPrintable

    • x86
    • windows_nt

      ###@###.###

      RFE: Wants a better way to ensure that memory allocated in native methods is cleaned up


      > Description:
      > Since Java classes do not have destructors it is difficult to ensure that memory is freed in classes that have native methods. E.g. if I do a malloc()from C in the constructor when I can do the free(). There are hints in the docs about finalization and a finalize() method but if I define such a method it appears not to be called and in fact the docs suggest that it is not guaranteed to be called. There are workarounds (E.g. allocate a byte array in Java and access it from C) but they are ugly. It wouldbe better if a class could reliably hook into the garbage collection mechanism so that it is notified when it is about to be collected. For pure Java classes this is unnecessary but it is very useful for classes with a non-Java implementation.

            sliangsunw Sheng Liang (Inactive)
            kasmithsunw Kevin Smith (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: