jersey
  1. jersey
  2. JERSEY-1681

Memory Leak in the basic Jersey webapp deploying on GFv312.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.11
    • Fix Version/s: 1.18, 2.0-rc1, 2.0
    • Component/s: None
    • Labels:
      None
    • Environment:

      Platform: GlassFish 3.1.2.2/3.1.2.4
      OS: Any OS
      Jersey: 1.11.1 --> 1.17 (tested)

      Description

      Deploying the simplest Jersey app, running to initialize to get a JAXB
      XML resource and undeploying it. Repeating this for a long time
      it is seen that GlassFish 3.1.x WebappClassLoader leaks and
      eventually gets OutOfMemoryError in PermGen space.

      The testcase is just a simple annotated Jersey Demarshaller to XML. (on GFv312 tip)
      and whatever Jersey 1.17 (used – including newest Jersey)
      It seems that when the JAXBContext is created it is kept in
      com.sun.jersey.core.provider.jaxb.AbstractJAXBProvider.jaxbContexts
      by the call com.sun.jersey.core.provider.jaxb.AbstractJAXBProvider.getStoredJAXBContext
      The jaxbContexts is a WeakHashMap keyed on a "Instance Object" (referrent) created
      on the WebappClassLoader and the value is the JAXBContextImpl

      It seems to be that the problem in theory with a WeakHashMap if the "Instance Object"
      has not strong reference the JAXBContextImpl will automatically be GC.
      But this is not the case since JAXBContextImpl itself holds the "Instance Object"
      within a collection. This implicitly make this object have a strong reference
      from JAXBContextImpl. Due to this the WebappClassLoader is not removed
      after a deploy/run/undeploy test.

      Side note
      -----------
      By the way, if bundling Jersey inside the webappp & setting GlassFish
      delegate=false classloader option, there is no leak (since the jersey is
      local and hence impervious to the issue).

        Activity

        Hide
        Jakub Podlesak added a comment -

        Fixed in both 1.x main trunk, and 2.0 master branch
        released Jersey 1.11.2 including the fix.

        Show
        Jakub Podlesak added a comment - Fixed in both 1.x main trunk, and 2.0 master branch released Jersey 1.11.2 including the fix.

          People

          • Assignee:
            Jakub Podlesak
            Reporter:
            gfuser9999
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 3 hours Original Estimate - 3 hours
              3h
              Remaining:
              Remaining Estimate - 0 minutes
              0m
              Logged:
              Time Spent - 4 hours
              4h