Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-7969

Memory leak in DiscoveryLiteDescriptor

    XMLWordPrintableJSON

Details

    Description

      As identified in volteanu's adaptTo presentation, it seems that Sling Discovery on Oak is consuming 42MB of RAM on a standard instance.

      Sling discovery deals with transient states (the views, leases, etc.) and is not caching significant amount of data. The 42MB figure for the discovery feature seems like a symptom of a memory leak.

      volteanu shared in his presentation that the 42MB worth of RAM was mainly consumed by a Json Factory reference. There is one static JsonReaderFactory in the discovery commons module, in the DiscoveryLiteDescriptor.

      Looking at the code, it seems that each invocation of the getDescriptorFrom method creates a JSON reader but never close it. This may may leave resources behind as hinted by the description of the close method in the API. AFAIK, the getDescriptorFrom is invoked periodically on a relatively high frequency (< seconds) which may be the trigger for the leak on all instances.

      This is only a supposition for now, it should be investigated further, simply by running a patched version of org.apache.sling.discovery.commons that make sure each JSON reader is properly closed.

      Attachments

        1. org.apache.sling.commons.johnzon-1.1.11-SLING-7969.jar
          144 kB
          Timothee Maret
        2. org.apache.sling.discovery.commons-1.0.23-SLING-7969.jar
          91 kB
          Timothee Maret
        3. Screenshot 2022-03-07 at 1.05.33 PM.png
          147 kB
          Sagar Miglani
        4. Screenshot 2022-03-07 at 1.14.57 PM.png
          176 kB
          Sagar Miglani
        5. Screenshot 2022-03-07 at 1.14.57 PM-1.png
          176 kB
          Sagar Miglani
        6. Screenshot 2022-03-07 at 1.18.07 PM.png
          26 kB
          Sagar Miglani
        7. Screenshot 2022-03-07 at 1.18.16 PM.png
          35 kB
          Sagar Miglani
        8. Screenshot 2022-03-07 at 12.26.11 PM.png
          35 kB
          Sagar Miglani

        Issue Links

          Activity

            People

              marett Timothee Maret
              marett Timothee Maret
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m