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

Attempt to dispose dialog may cause huge memory leak

    XMLWordPrintable

Details

    • Bug
    • Resolution: Cannot Reproduce
    • P2
    • 8
    • 7
    • client-libs
    • None
    • generic
    • generic

    Description

      As part of change for 7016482 we tried to ensure dialog is properly disposed when closed by click on X button:
        http://sa.sfbay.sun.com/projects/deployment_data/7u2/7016482.0/src/common/share/classes/com/sun/deploy/ui/DialogTemplate.java.sdiff.html

      Specifics of DialogTemplate is that it will create dummy frame if dialog has no parent and logic to hide and dispose this frame is in the
      DialogTemplate.setVisible() as:

      1877 public void setVisible(boolean visible) {
      1878 if (visible) {
      1879 final DialogListener dl = UIFactory.getDialogListener();
      1880 final JDialog dlg = dialog;
      1881 final Frame dummy = dummyFrame;
      1882 Runnable runner = new Runnable() {
      1883 public void run() {
      1884 if (dl != null) {
      1885 dl.beforeShow();
      1886 }
      1887 dlg.pack();
      1888 if (dummy != null) {
      1889 dummy.setVisible(true);
      1890 }
      1891 dlg.setVisible(true);
      1892 }
      1893 };
      1894
      1895 if (SwingUtilities.isEventDispatchThread()) {
      1896 runner.run();
      1897 } else {
      1898 try {
      1899 SwingUtilities.invokeAndWait(runner);
      1900 } catch (Exception e) {
      1901 Trace.ignored(e);
      1902 }
      1903 }
      1904 } else {
      1905 dialog.setVisible(false);
      1906 dialog.dispose();
      1907 if (dummyFrame != null) {
      1908 dummyFrame.setVisible(false);
      1909 dummyFrame.dispose();
      1910 }
      1911 }
      1912
      1913 }

      What we observe with this change is that when dialog is closed in the normal way, e.g. by clicking on "Run" button in the Security dialog
      then memory is starting to leak at fast rate.

      To reproduce:
        1) install jdk7u2 b08
        2) Open Java control panel to enable java console to be shown
        3) Open http://javaweb.sfbay.sun.com/~nn136682/SignedArcTest/noredirect.html, press Run when you see security dialog
        4) Keep pressing m for memory info dump in java console. Observe heap consumption and heap size increase
           (if correct plugin is used then version printed in java console should be "Java Plugin-in 10.2.0.8)

      Eventually (in 5 mins) it will fail with OOM after eating all 256Mb of the heap.

      Here is the problematic stactrace:

      ===========
      Exception in thread "AWT-EventQueue-1" java.lang.OutOfMemoryError:
      Java heap space
      at java.util.Arrays.copyOf(Arrays.java:2367)
      at java.lang.String.<init>(String.java:197)
      at sun.util.locale.LocaleUtils.toLowerString(LocaleUtils.java:105)
      at sun.util.locale.LanguageTag.parse(LanguageTag.java:191)
      at java.util.Locale.forLanguageTag(Locale.java:1465)
      at sun.awt.windows.WInputMethod.getNativeLocale(Native Method)
      at sun.awt.windows.WToolkit.getDefaultKeyboardLocale(WToolkit.java:717)
      at sun.awt.im.ExecutableInputMethodManager.getDefaultKeyboardLocale(InputMethodManager.java:593)
      at sun.awt.im.InputContext.<init>(InputContext.java:131)
      at sun.awt.im.InputMethodContext.<init>(InputMethodContext.java:89)
      at java.awt.im.InputContext.getInstance(InputContext.java:92)
      at java.awt.Window.getInputContext(Window.java:1413)
      at java.awt.Component.getInputContext(Component.java:6024)
      at java.awt.Component.getInputContext(Component.java:6024)
      at java.awt.Component.getInputContext(Component.java:6024)
      at java.awt.Component.getInputContext(Component.java:6024)
      at java.awt.Component.getInputContext(Component.java:6024)
      at java.awt.Component.removeNotify(Component.java:6985)
      at java.awt.Container.removeNotify(Container.java:2816)
      at javax.swing.JComponent.removeNotify(JComponent.java:4761)
      at javax.swing.AbstractButton.removeNotify(AbstractButton.java:1031)
      at javax.swing.JButton.removeNotify(JButton.java:235)
      at java.awt.Container.removeNotify(Container.java:2800)
      at javax.swing.JComponent.removeNotify(JComponent.java:4761)
      at java.awt.Container.removeNotify(Container.java:2800)
      at javax.swing.JComponent.removeNotify(JComponent.java:4761)
      at java.awt.Container.removeNotify(Container.java:2800)
      at javax.swing.JComponent.removeNotify(JComponent.java:4761)
      at java.awt.Container.removeNotify(Container.java:2800)
      at javax.swing.JComponent.removeNotify(JComponent.java:4761)
      at javax.swing.JRootPane.removeNotify(JRootPane.java:764)
      at java.awt.Container.removeNotify(Container.java:2800)
      Memory: 253,440K Free: 227,193K (89%) ... completed.
      Garbage collect ... completed.
      Memory: 233,732K Free: 222,134K (95%) ... completed.
      Finalize objects on finalization queue ... completed.
      Memory: 233,732K Free: 218,901K (93%) ... completed.

      Attachments

        Issue Links

          Activity

            People

              denis Denis Fokin (Inactive)
              igor Igor Nekrestyanov (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: