Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
does subwindow cause browser memory leak?
hi,I wrote a test application and found that everytime I close the sub-window, the browser's memory did not decrease. will you please tell me why is that? thank you!
package com.example.topnewform;
import java.util.HashMap;
import com.vaadin.Application;
import com.vaadin.ui.Button;
import com.vaadin.ui.Window;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Window.CloseEvent;public class TopnewformApplication extends Application {
/**
*
*/
private static final long serialVersionUID = -8681400824585178761L;
@Override
public void init() {
final Window mainWindow = new Window("Topnewform Application");
Button btn = new Button();
btn.setCaption("add");
btn.addListener(new Button.ClickListener() {/**
*
*/
private static final long serialVersionUID = -6562244480021067904L;public void buttonClick(ClickEvent event) {
// TODO Auto-generated method stub
for (int i = 0; i < 20; i++) {
Window wnd = new Window();
wnd.addListener(new Window.CloseListener() {/**
*
*/
private static final long serialVersionUID = -1324839086947657951L;public void windowClose(CloseEvent e) {
// TODO Auto-generated method stub
mainWindow.removeWindow(e.getWindow());
System.out.println(e.getWindow() + " removed2!");
}
});
wnd.setModal(false);
wnd.setImmediate(false);
mainWindow.addWindow(wnd);
System.out.println(wnd + " added!");
wnd = null;
}
}
});
Button btn1 = new Button();
btn1.setCaption("remove");
btn1.addListener(new Button.ClickListener() {/**
*
*/
private static final long serialVersionUID = 2342008830092155491L;public void buttonClick(ClickEvent event) {
while (!mainWindow.getChildWindows().isEmpty())
{
Window w = mainWindow.getChildWindows().iterator().next();
mainWindow.removeWindow(w);
System.out.println(w + " removed!");
w = null;
}
}
});
mainWindow.addComponent(btn);
mainWindow.addComponent(btn1);
setMainWindow(mainWindow);
}}
Hi,
It looks to me that a list used in ordering sub windows is not correctly cleaned. That may cause quite sever leak in apps that rely heavily on sub windows. I created a ticket for it.
http://dev.vaadin.com/ticket/8597
cheers,
matti