- 
    Bug 
- 
    Resolution: Duplicate
- 
     P4 P4
- 
    None
- 
    fx2.1
- 
    None
                    See here:
https://forums.oracle.com/forums/thread.jspa?threadID=2407365
I have a similar issue, too, where I reuse the stage with different scenes.
The following example doesn't make sense, but shows the memory leak. (just change the loop count).
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class TestApp extends Application {
public static void main(String[] args) throws Exception {
launch();
}
public void start(final Stage stage) throws Exception {
for (int i = 0; i < 4000; i++) {
stage.setScene(new Scene(new VBox()));
}
System.gc();
System.out.println((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024 + " KB");
stage.show();
}
}
https://forums.oracle.com/forums/thread.jspa?threadID=2407365
I have a similar issue, too, where I reuse the stage with different scenes.
The following example doesn't make sense, but shows the memory leak. (just change the loop count).
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class TestApp extends Application {
public static void main(String[] args) throws Exception {
launch();
}
public void start(final Stage stage) throws Exception {
for (int i = 0; i < 4000; i++) {
stage.setScene(new Scene(new VBox()));
}
System.gc();
System.out.println((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024 + " KB");
stage.show();
}
}
- duplicates
- 
                    JDK-8118626 Scene not getting garbage collected -           
- Closed
 
-         
- relates to
- 
                    JDK-8118626 Scene not getting garbage collected -           
- Closed
 
-