-
Bug
-
Resolution: Cannot Reproduce
-
P3
-
8u72
-
x86_64
-
windows_7
FULL PRODUCT VERSION :
java version "1.8.0_72-ea"
Java(TM) SE Runtime Environment (build 1.8.0_72-ea-b05)
Java HotSpot(TM) 64-Bit Server VM (build 25.72-b05)
ADDITIONAL OS VERSION INFORMATION :
ver 6.1 - Windows 7 Professional, Version 6.1 (Build 7601, Service Pack 1)
A DESCRIPTION OF THE PROBLEM :
Multiple Tabs are opened in a TabPane. Each Tab contains a WebView. When the Tabs are closed WebView does not (never) release resources.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the example code below or the java file I have sent. The example display 4 Tabs, the first 3 tabs display web pages, the 4th Tab is empty. Wait for the display to complete, then check the memory use:
- 500-600Mb in Windows Task Manager (400Mb in JDK9)
- heap size 350Mb in NetBeans profiler
Now close the first 3 Tabs, leaving one empty Tab and the resources are never released, both memory use and heap size remain constant.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Memory use and heap size should reduce as the Tabs are closed.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
I have also sent a java file with this code:
package webviewmemory;
import javafx.application.Application;
import javafx.concurrent.Worker;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
public class WebViewMemory extends Application {
@Override
public void start(Stage primaryStage) {
TabPane tabPane= new TabPane();
TabPage tab1= new TabPage("http:\\www.yahoo.com");
TabPage tab2= new TabPage("http:\\www.marketwatch.com");
TabPage tab3= new TabPage("http:\\www.bbc.com");
TabPage tab4= new TabPage(null);
tabPane.getTabs().addAll(tab1,tab2,tab3,tab4);
Scene scene = new Scene(tabPane, 1024, 800);
primaryStage.setTitle("WebView Memory Problem");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
class TabPage extends Tab {
TabPage thisTab;
WebEngine thisEngine;
TabPage(String urlString) {
thisTab= this;
if(urlString==null) {
this.setText("new");
this.setClosable(false);
}
else {
this.setText(urlString);
WebView browser = new WebView();
browser.getEngine().load(urlString);
thisEngine= browser.getEngine();
this.setContent(browser);
this.setOnClosed(new EventHandler<Event>() {
@Override
public void handle(Event event) {
thisTab.setContent(null);
thisTab= null;
thisEngine.setJavaScriptEnabled(false);
Worker worker= thisEngine.getLoadWorker();
if(worker.isRunning()) worker.cancel();
thisEngine.loadContent(null);
thisEngine= null;
}
});
}
}
}
---------- END SOURCE ----------
java version "1.8.0_72-ea"
Java(TM) SE Runtime Environment (build 1.8.0_72-ea-b05)
Java HotSpot(TM) 64-Bit Server VM (build 25.72-b05)
ADDITIONAL OS VERSION INFORMATION :
ver 6.1 - Windows 7 Professional, Version 6.1 (Build 7601, Service Pack 1)
A DESCRIPTION OF THE PROBLEM :
Multiple Tabs are opened in a TabPane. Each Tab contains a WebView. When the Tabs are closed WebView does not (never) release resources.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the example code below or the java file I have sent. The example display 4 Tabs, the first 3 tabs display web pages, the 4th Tab is empty. Wait for the display to complete, then check the memory use:
- 500-600Mb in Windows Task Manager (400Mb in JDK9)
- heap size 350Mb in NetBeans profiler
Now close the first 3 Tabs, leaving one empty Tab and the resources are never released, both memory use and heap size remain constant.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Memory use and heap size should reduce as the Tabs are closed.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
I have also sent a java file with this code:
package webviewmemory;
import javafx.application.Application;
import javafx.concurrent.Worker;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
public class WebViewMemory extends Application {
@Override
public void start(Stage primaryStage) {
TabPane tabPane= new TabPane();
TabPage tab1= new TabPage("http:\\www.yahoo.com");
TabPage tab2= new TabPage("http:\\www.marketwatch.com");
TabPage tab3= new TabPage("http:\\www.bbc.com");
TabPage tab4= new TabPage(null);
tabPane.getTabs().addAll(tab1,tab2,tab3,tab4);
Scene scene = new Scene(tabPane, 1024, 800);
primaryStage.setTitle("WebView Memory Problem");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
class TabPage extends Tab {
TabPage thisTab;
WebEngine thisEngine;
TabPage(String urlString) {
thisTab= this;
if(urlString==null) {
this.setText("new");
this.setClosable(false);
}
else {
this.setText(urlString);
WebView browser = new WebView();
browser.getEngine().load(urlString);
thisEngine= browser.getEngine();
this.setContent(browser);
this.setOnClosed(new EventHandler<Event>() {
@Override
public void handle(Event event) {
thisTab.setContent(null);
thisTab= null;
thisEngine.setJavaScriptEnabled(false);
Worker worker= thisEngine.getLoadWorker();
if(worker.isRunning()) worker.cancel();
thisEngine.loadContent(null);
thisEngine= null;
}
});
}
}
}
---------- END SOURCE ----------