Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8272158

SoftReference related bugs under memory pressure

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 18
    • 17, 18
    • tools
    • b11
    • generic
    • generic

      Javadoc uses the SoftReference class in various places to cache per-element computed objects. Running javadoc under memory pressure reveals some problems with these caches.

       - in class VisibleMemberTable there is a bug in how SoftReferences are used to cache ImplementedMethod instances: The SoftReference.get() method is invoked two times, once to check whether the referenced value is null, and the second time to return the value. If the object is garbage-collected between the calls, null is returned.

       - Soft references are used to cache CommentHelper instances. However, there is one instance where special information is stored in a CommentHelper instance that cannot be restored if the instance is garbage collected and recreated later. This happens in MemberSummaryBuilder.buildSummary method when the CommentHelper.setOverrideElement method is invoked.

      While the first problem is easy to fix, the second one is a bit harder. Two solutions would be to either use hard references to store the CommentHelper instances, or create a way to restore the information in case the object has to be recreated.

            hannesw Hannes Wallnoefer
            hannesw Hannes Wallnoefer
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: