-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
8u101
-
x86
-
other
FULL PRODUCT VERSION :
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Windows 7, 10, Server 2008, Server 2012
Linux (multiple)
A DESCRIPTION OF THE PROBLEM :
When using software rendering in javaFX (-Dprism.order=sw), certain scene graph manipulations cause instances of com.sun.pisces.JavaSurface to not be garbage collected.
The supplied reproducer code shows an FX application with a single button. This button alternately adds and removes a ScrollPane containing a TableView element to the GUI.
Profiling this application shows that each addition creates a new JavaSurface instance (which contains an INT buffer). This instance is not removed by garbage collection after it is removed from the scene graph, causing an accumulation of these objects.
This bug is closely related to another reported bug [1], but the effect is more dramatic.
[1] http://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8163079
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run the provided source code.
Click the GUI button repeatedly.
Profile the running application.
Observe the increasing number of JavaSurfae instances, which do not get garbage collected.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
JavaSurface objects are garbage colelcted at some point
ACTUAL -
Objects remain indefinitely
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class LeakProducer extends Application {
@Override
public void start(Stage primaryStage) {
final StackPane root = new StackPane();
final VBox myBox = new VBox();
Button tabBarBtn = new Button();
tabBarBtn.setText("TableView");
tabBarBtn.setOnAction(x -> {
if (myBox.getChildren().size() > 1) {
myBox.getChildren().remove(1);
System.gc();
System.runFinalization();
} else {
ScrollPane sp = new ScrollPane();
sp.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
sp.setVbarPolicy(ScrollPane.ScrollBarPolicy.ALWAYS);
TableView<TableColumn> table = new TableView<>();
TableColumn firstNameCol = new TableColumn("First Name");
TableColumn lastNameCol = new TableColumn("Last Name");
TableColumn emailCol = new TableColumn("Email");
table.getColumns().addAll(firstNameCol, lastNameCol, emailCol);
sp.setContent(table);
myBox.getChildren().add(sp);
}
});
Scene scene = new Scene(root, 300, 250);
myBox.getChildren().add(tabBarBtn);
root.getChildren().addAll(myBox);
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
System.out.println("===============================");
System.out.println("Java Version: " + System.getProperty("java.version"));
System.out.println("===============================");
launch(args);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Use hardware rendering
SUPPORT :
YES
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Windows 7, 10, Server 2008, Server 2012
Linux (multiple)
A DESCRIPTION OF THE PROBLEM :
When using software rendering in javaFX (-Dprism.order=sw), certain scene graph manipulations cause instances of com.sun.pisces.JavaSurface to not be garbage collected.
The supplied reproducer code shows an FX application with a single button. This button alternately adds and removes a ScrollPane containing a TableView element to the GUI.
Profiling this application shows that each addition creates a new JavaSurface instance (which contains an INT buffer). This instance is not removed by garbage collection after it is removed from the scene graph, causing an accumulation of these objects.
This bug is closely related to another reported bug [1], but the effect is more dramatic.
[1] http://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8163079
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run the provided source code.
Click the GUI button repeatedly.
Profile the running application.
Observe the increasing number of JavaSurfae instances, which do not get garbage collected.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
JavaSurface objects are garbage colelcted at some point
ACTUAL -
Objects remain indefinitely
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class LeakProducer extends Application {
@Override
public void start(Stage primaryStage) {
final StackPane root = new StackPane();
final VBox myBox = new VBox();
Button tabBarBtn = new Button();
tabBarBtn.setText("TableView");
tabBarBtn.setOnAction(x -> {
if (myBox.getChildren().size() > 1) {
myBox.getChildren().remove(1);
System.gc();
System.runFinalization();
} else {
ScrollPane sp = new ScrollPane();
sp.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
sp.setVbarPolicy(ScrollPane.ScrollBarPolicy.ALWAYS);
TableView<TableColumn> table = new TableView<>();
TableColumn firstNameCol = new TableColumn("First Name");
TableColumn lastNameCol = new TableColumn("Last Name");
TableColumn emailCol = new TableColumn("Email");
table.getColumns().addAll(firstNameCol, lastNameCol, emailCol);
sp.setContent(table);
myBox.getChildren().add(sp);
}
});
Scene scene = new Scene(root, 300, 250);
myBox.getChildren().add(tabBarBtn);
root.getChildren().addAll(myBox);
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
System.out.println("===============================");
System.out.println("Java Version: " + System.getProperty("java.version"));
System.out.println("===============================");
launch(args);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Use hardware rendering
SUPPORT :
YES
- duplicates
-
JDK-8163079 Memory leak in JavaFX with software rendering pipeline
-
- Open
-