Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-72438

High memory allocations when parsing update-center.json with json-lib-2.4-jenkins-3

      We experienced high memory allocations when jenkins tried to check for plugin updates. Our product showed increased allocations when parsing current 2.8MB update-center.json

      On prod instances this was about 170 GB of allocations within a minute. 

       

      I was able to reproduce it locally using IntelliJ profiler which showed about 80 GB of allocations when parsing update-center.json with the JsonTokener (https://github.com/jenkinsci/json-lib/blob/master/src/main/jdk15/net/sf/json/JSONObject.java#L829)

      culprit seems to be a null matcher which is recursively called and performs substring operations.

      https://github.com/jenkinsci/json-lib/blob/master/src/main/java/net/sf/json/util/JSONTokener.java#L117

       

      Not sure how big the impact on this is or will be, just wanted to mention it here as this drove some of our (already close to memory limit) instances OOM. 

          [JENKINS-72438] High memory allocations when parsing update-center.json with json-lib-2.4-jenkins-3

          Basil Crow added a comment -

          I cannot see anything nearly this dramatic when running Jenkins 2.414.1 on Java 17. I do see an increase in heap usage from 65 MB to 1304 MB after refreshing the Update Center, but nothing approaching heap capacity.

          Basil Crow added a comment - I cannot see anything nearly this dramatic when running Jenkins 2.414.1 on Java 17. I do see an increase in heap usage from 65 MB to 1304 MB after refreshing the Update Center, but nothing approaching heap capacity.

          Hi basil,

          the allocations are not filling heap, this is just about allocations, it gets GCd pretty fast but still induces memory churn. 

          Leon Schiesswald added a comment - Hi basil , the allocations are not filling heap, this is just about allocations, it gets GCd pretty fast but still induces memory churn. 

          Basil Crow added a comment -

          If the allocations are being garbage collected then I do not see a practical issue.

          Basil Crow added a comment - If the allocations are being garbage collected then I do not see a practical issue.

          Basil Crow added a comment -

          Duplicates JENKINS-67344.

          Basil Crow added a comment - Duplicates  JENKINS-67344 .

            Unassigned Unassigned
            leon_schiesswald Leon Schiesswald
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: