uel
  1. uel
  2. UEL-23

com.sun.el.lang.ExpressionBuilder

    Details

      Description

      We have application which is leaking memory from cache inside com.sun.el.lang.ExpressionBuilder. Basically cache implementation is leaking keys in the cache as values get released as soft refs but keys are leaking. After 6hrs into the test there 268182 entries in ExpressionBuilder.cache where soft refs are gone and cache pins total of 117MB of memory. Then after 22h into the test there are 485497 entries in ExpressionBuilder.cache where soft refs are gone and cache pins total of 221MB of memory. This is very big leak

      The main issue is that cache implementation is unbounded with keys leaking. The code needs to make sure it prunes keys whose soft refs are gone, potentially by using ReferenceQueue

        Activity

        Hide
        kchung added a comment -

        I fixed the leak by also making a SoftReference of the key, and add a ReferenceQueue to monitor the keys are removed by the garbage collector. There is now a check on the ReferenceQueue on the put method to see if there are any entries in the queue, and if so, empty the queue and remove the corresponding entries in the HashMap.

        Hopefully the performance won't be too much affected by this change.

        Attached are the two jars. The change is in el-impl.jar only. The jars will be placed in the maven repo later. These jar are here for the impatient.

        Show
        kchung added a comment - I fixed the leak by also making a SoftReference of the key, and add a ReferenceQueue to monitor the keys are removed by the garbage collector. There is now a check on the ReferenceQueue on the put method to see if there are any entries in the queue, and if so, empty the queue and remove the corresponding entries in the HashMap. Hopefully the performance won't be too much affected by this change. Attached are the two jars. The change is in el-impl.jar only. The jars will be placed in the maven repo later. These jar are here for the impatient.
        Hide
        kchung added a comment -

        New and improved. Thanks to Stevan

        Show
        kchung added a comment - New and improved. Thanks to Stevan

          People

          • Assignee:
            kchung
            Reporter:
            smalesev
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: