Menu

#378 AWT Windows leaked by ToolboxSignonHandler

Sign-on
open
wanghuiq
None
5
2016-10-09
2016-10-07
Carey Evans
No

Each time the ToolboxSignonHandler displays a password dialog, it leaks two AWT windows that it creates but does not call dispose() on, at the start of setupPasswordDialog(). I can see these windows living forever by calling java.awt.Window.getWindows(). These AWT windows each have native peers, so I expect that could see leaked handles in MS Windows if I had the tools.

For my application, I've written code which cleans these up when I might be exiting:

for (Window w : Window.getWindows()) {
    Window[] ownedWindows = w.getOwnedWindows();
    if (w instanceof PasswordDialog) {
        log.info("Disposing leftover window {}", w);
        w.dispose();
    } else if (ownedWindows.length == 1 && ownedWindows[0] instanceof PasswordDialog) {
        log.info("Disposing hidden parent {}", w);
        w.dispose();
    } else {
        log.info("Unknown window {}", w);
    }
}

After this runs, the application can exit when finished without my code needing to call System.exit() at the right time. However, these should really be disposed of by ToolboxSignonHandler, along with MessageDialog if a message is displayed.

Discussion

  • Carey Evans

    Carey Evans - 2016-10-08

    I've confirmed with Nir Sofer's WinLister from http://www.nirsoft.net/utils/winlister.html that native window handles appear to be getting leaked as well. The attachment shows one normal AWT hidden window, and four leaked PasswordDialog windows, after prompting for a password twice.

     
  • John Eberhard

    John Eberhard - 2016-10-09
    • assigned_to: wanghuiq
     

Log in to post a comment.

MongoDB Logo MongoDB