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

The Disposer thread could cause memory leaks in user applications

    XMLWordPrintable

Details

    • 2d
    • generic
    • generic

    Description

      To dispose of Java2D-related resources we
        (Java2D) create a Java2D-Disposer thread
        the first time any Java2D-related activity
        is encountered (it is started from static block
        of Disposer class). This thread then lives
        forever.

        There is a couple of problems: first, if the
        customer's thread has an InheritableThreadLocal,
        our thread inherits it and thus it never gets
        disposed of even if customer's thread went away.

        This is not specific to our Disposer
        thread - if, say, an EventDispatchThread is started
        from the customer's thread it could also run
        into this issue.

        Another issue is that the Disposer thread
        inherits the parent thread's contextClassLoader,
        and since our thread lives forever, any classes
        referenced by that loader are not being collected
        (and since those could be customer's classes, they
        could contain some large data, leading to huge
        memory leaks).

      Here's a thread which started the discussion:
         http://forums.java.net/jive/thread.jspa?messageID=169608&#169608

      Attachments

        Issue Links

          Activity

            People

              scfitch Stephen Fitch
              tdv Dmitri Trembovetski (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: