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

ObjectStreamClass caches keep ClassLoaders alive

    XMLWordPrintable

Details

    • b02
    • generic
    • generic
    • Verified

    Backports

      Description

        The caches in ObjectStreamClass basically map WeakReference<Class> to SoftReference<ObjectStreamClass>, where the ObjectStreamClass also references the same Class. That means that the cache entry, and thus the class and its class-loader, will not get reclaimed, unless the GC determines that memory pressure is very high.

        However, this seems bogus, because that unnecessarily keeps ClassLoaders and all its classes alive much longer than necessary: as soon as a ClassLoader (and all its classes) become unreachable, there is no point in retaining the stuff in OSC's caches.

        This can be demonstrated by compiling the attached .java files, and run:
        java TestObjectStreamClass

        Attachments

          Issue Links

            Activity

              People

                rkennke Roman Kennke
                rkennke Roman Kennke
                Votes:
                0 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: