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

MethodType leaks memory due to interning

    XMLWordPrintable

    Details

      Backports

        Description

        MethodType objects are interned and unique MethodType object is maintained for a specific combination of parameter types and return type. This is done by interning MethodType objects using a static final HashMap called "internTable" in MethodType class. This leads to Class objects being leaked. If user code creates a MethodType object using any user-defined Class, then the corresponding MethodType ends up stored in this HashMap and so user's class is prevented from being GC'ed. All classes loaded by defining loader of such class and all reachable objects from static fields of such classes are also kept alive. The only workaround now is to avoid creating MethodTypes with any user defined Class object. This workaround implies we can create MethodHandles on virtual methods of user's classes. This is because "this" type of such methods will be user defined Class and so that will be leaked into JDK's internTable.

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                jrose John Rose
                Reporter:
                sundar Sundararajan Athijegannathan
                Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: