Uploaded image for project: 'Application Server 7'
  1. Application Server 7
  2. AS7-3733

AWT AppContext / EventQueue ClassLoader Memory Leaks

    XMLWordPrintable

Details

    Description

      The use of libraries using awt components creates ClassLoader Memory Leaks. This is because the first call to the sun AppContext class makes a static reference to the current class loader.
      Same thing goes with the creation of the AWT Event Queue, as an example the use of the class java.awt.Color makes a static init call to java.awt.Toolkit which creates an AWT EventQueue despite the headless mode. The EventQueue also keep a reference to the current context with the class loader.

      The current work around I've found is to add a call to:

      java.awt.Toolkit.getDefaultToolkit();

      before the application gets loaded.
      This causes the EventQueue to be created and the AppContext to be initialized.
      Then, as the AWT static references are final, I get rid of this issue for the rest of the server lifecycle.
      I put this code in org.jboss.as.server.Main, just after line 91. However a proper solution would be to use org.apache.catalina.core.JreMemoryLeakPreventionListener which is present in the JBoss Web jar but not used... (cf. https://community.jboss.org/thread/164760 ) However the Tomcat code deals only with the AppContext, not the EventQueue!

      Attachments

        Activity

          People

            rmaucher Remy Maucherat
            guinotphil Philippe Guinot (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: