-
Bug
-
Resolution: Cannot Reproduce
-
P4
-
7u6
-
Windows 7
java version "1.7.0_11"
Java(TM) SE Runtime Environment (build 1.7.0_11-b21)
Java HotSpot(TM) Client VM (build 23.6-b04, mixed mode, sharing)
------------------------------
main.css (bg.png size: 85.2K)
------------------------------
#bg
{
-fx-background-image : url('images/bg.png');
-fx-background-size: stretch;
-fx-background-position: left top;
-fx-background-repeat: no-repeat;
}
-------------------------------------
CssMemoryLeakTest.java
-------------------------------------
public class CssMemoryLeakTest extends Application {
private StackPane root;
private Button btn;
@Override
public void start(Stage primaryStage) {
btn = new Button();
btn.setText("Say 'Memory Leak'");
btn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
VBox box = new VBox();
box.getStylesheets().add(getClass().getResource("resource/main.css").toExternalForm());
box.setId("bg");
root.getChildren().setAll(box, btn);
}
});
root = new StackPane();
root.getChildren().add(btn);
Scene scene = new Scene(root, 300, 250);
primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
----------------------------------------
It just took 4MB at the beginingļ¼
after clicking the button 20 times, the memory increase to 200MB
But, applying the same css file to the Scene, that would not happen
BTW: It took me 2 days to locate this problem... orz
main.css (bg.png size: 85.2K)
------------------------------
#bg
{
-fx-background-image : url('images/bg.png');
-fx-background-size: stretch;
-fx-background-position: left top;
-fx-background-repeat: no-repeat;
}
-------------------------------------
CssMemoryLeakTest.java
-------------------------------------
public class CssMemoryLeakTest extends Application {
private StackPane root;
private Button btn;
@Override
public void start(Stage primaryStage) {
btn = new Button();
btn.setText("Say 'Memory Leak'");
btn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
VBox box = new VBox();
box.getStylesheets().add(getClass().getResource("resource/main.css").toExternalForm());
box.setId("bg");
root.getChildren().setAll(box, btn);
}
});
root = new StackPane();
root.getChildren().add(btn);
Scene scene = new Scene(root, 300, 250);
primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
----------------------------------------
It just took 4MB at the beginingļ¼
after clicking the button 20 times, the memory increase to 200MB
But, applying the same css file to the Scene, that would not happen
BTW: It took me 2 days to locate this problem... orz