简体   繁体   中英

JavaFX memory consumption on window resizing operations

I have code that makes simple window without any functionality. After the program started: process explorer says that it consumes ~50Mb ram. But when user start to resizing window by dragging borders the consumption is rapidly grows (up to 500Mb). Consumption does not decrease after the cessation of the resizing.

What is the reason of such behavior?

// sample
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;

public class MainApp extends Application{
    @Override
    public void start(Stage stage) throws Exception {
        BorderPane borderPane = new BorderPane();
        Scene scene = new Scene(borderPane, 300, 300);

        stage.setTitle("Leak");
        stage.setScene(scene);
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}

Welcome to the world of java, where garbage collection is done, when it's done. At least in all cases where you use the defaults. Resizing a window fires some events and there is quite a lot going on the javafx, so do not worry to much about it. In doubt you can startup java's profiler and for fun, you can have a look at all the fancy stuff going on using debugging.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM