jaxb
  1. jaxb
  2. JAXB-978

UnmarshallerImpl has an ineffective finalize() method

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.2.4u2, 2.2.5, 2.2.6, 2.2.7
    • Fix Version/s: None
    • Component/s: runtime
    • Labels:
      None

      Description

      During upgrading a web service we observed that a the Parallel new garbage collector was unable to achieve the previously seen thoughput when running with JAXB 2.2.5+

      On investigation it seems the reason for this is the addition of the `finalize()` method on `UnmarshallerImpl`, this causes the object not to be collected but to be placed to to the finalizer queue. This is problematic for two reasons

      • it increases the contention on the finalizer queue
      • The last unmarshalled object (a large WS response object in our case) is retained until the finalizer invokes the `finalize()` method

      In addition, the implementation of the `finalize()` method:

         protected void finalize() throws Throwable {
              try {
                  ClassFactory.cleanCache();
              } finally {
                  super.finalize();
              }
          }
      

      is broken because the `ClassFactory.cleanCache()` method needs to be called in the same thread as the original use of the `Unmarshaller`, but this won't be true as it will be called the Finalizer thread.

      Will be posting a patch to remove the method to the dev mailing list.

        Activity

        Hide
        Iaroslav Savytskyi added a comment -

        Hi,

        Thanks for reporting. I'll fix it.

        Show
        Iaroslav Savytskyi added a comment - Hi, Thanks for reporting. I'll fix it.
        Hide
        rshekar added a comment -

        Hi Iaroslav,

        I am seeing a similar issue when using CXF client, 50% of the heap is java.lang.ref.Finalizer objects.

        Can you please let me know if the fix planned for a release, and if so any ETA.

        Thank you,
        Raj.

        Show
        rshekar added a comment - Hi Iaroslav, I am seeing a similar issue when using CXF client, 50% of the heap is java.lang.ref.Finalizer objects. Can you please let me know if the fix planned for a release, and if so any ETA. Thank you, Raj.
        Hide
        Iaroslav Savytskyi added a comment -

        The problem is that we are not able to determine when we have to clean our cache.

        I think we will try to do something with this in 2.2.8... But unfortunately I'm not able to give any estimations when we will start working on this. This year???

        Show
        Iaroslav Savytskyi added a comment - The problem is that we are not able to determine when we have to clean our cache. I think we will try to do something with this in 2.2.8... But unfortunately I'm not able to give any estimations when we will start working on this. This year???
        Hide
        gadavis added a comment -

        how you clear the cache isn't really important to removing this finalise method. The finalise method does nothing to clear the cache and only messes with the garbage collector.

        Show
        gadavis added a comment - how you clear the cache isn't really important to removing this finalise method. The finalise method does nothing to clear the cache and only messes with the garbage collector.

          People

          • Assignee:
            Iaroslav Savytskyi
            Reporter:
            gadavis
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: