Javafx应用程序占用太多内存
我正在使用java profiler测试我的应用程序。在Javafx应用程序占用太多内存,java,javafx,Java,Javafx,我正在使用java profiler测试我的应用程序。在遥测配置文件下,我注意到它占用了太多内存,我认为它是我项目中的类,所以我做了一个对象配置文件,发现它不是我的对象,事实上最高的对象只消耗了6400B,然后我测试了我项目中的所有对象,并实现了字节[]上升到了13000000b但是我的程序完全没有做任何事情,我哪里出了问题?这是我的JavaFx主类的一部分 public class MainController implements Initializable, EventHandler<
遥测
配置文件下,我注意到它占用了太多内存,我认为它是我项目中的类,所以我做了一个对象
配置文件,发现它不是我的对象,事实上最高的对象只消耗了6400B,然后我测试了我项目中的所有对象,并实现了字节[]
上升到了13000000b
但是我的程序完全没有做任何事情,我哪里出了问题?这是我的JavaFx主类的一部分
public class MainController implements Initializable, EventHandler<ActionEvent> {
@FXML
private Label lblNumber;
@FXML
private Label lblDate;
@FXML
private Label lblAuthId;
@FXML
private JFXButton btnStart;
@FXML
private JFXButton btnStop;
@FXML
private Label lblAdImageName;
@FXML
private JFXButton btnChangeAdImage;
@FXML
private JFXButton btnImageSetting;
@FXML
private JFXSlider sldScale;
@FXML
private JFXSlider sldRotate;
@FXML
private AnchorPane anchorImageSettings;
@FXML
private VBox anchorLotto;
@FXML
private JFXToggleButton togglePanDrag;
@FXML
private JFXSlider sldPan;
@FXML
private Clock clockAnalogue;
@FXML
private JFXButton btnAddDraw;
@FXML
private Label lblDrawName;
@FXML
private Label lblPosition;
@FXML
private Label lblPrize;
@FXML
private Label lblStatus;
@FXML
private Label lblNumOfWinners;
@FXML
private AnchorPane anchorPane;
@FXML
private JFXTabPane tabPane;
@FXML
private StackPane stackPane;
private Database database;
private ScheduledExecutorService databaseExecutor;
public static Entry entry;
private volatile boolean isRunning;
private boolean isLoadedSuccessfully;
private AppPreferences preferences;
private boolean isDrawSession;
private Draw draw;
private int currentPosition = -1;
private int screenWidth, screenHeight;
private Position pos;
@Override
public void initialize(URL url, ResourceBundle rb) {
disableAllViews();
setDefaultValues();
configureDrawPane();
entry = new Entry();
preferences = new AppPreferences();
database = new Database();
GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
this.screenWidth = gd.getDisplayMode().getWidth();
this.screenHeight = gd.getDisplayMode().getHeight();
tabPane.prefWidthProperty().bind(anchorPane.widthProperty());
tabPane.prefHeightProperty().bind(anchorPane.heightProperty());
this.lblNumber.setMaxWidth(Double.MAX_VALUE);
this.lblNumber.setAlignment(Pos.CENTER);
clockAnalogue.setTextVisible(true);
clockAnalogue.setSecondsVisible(true);
clockAnalogue.setDateVisible(true);
clockAnalogue.setDateColor(Color.BLACK);
clockAnalogue.setHourColor(Color.RED);
clockAnalogue.setRunning(false);
fadeInImageSettings.setNode(anchorImageSettings);
fadeInImageSettings.setFromValue(0.0);
fadeInImageSettings.setToValue(1.0);
fadeInImageSettings.setCycleCount(1);
fadeInImageSettings.setAutoReverse(false);
fadeInLotto.setNode(anchorLotto);
fadeInLotto.setFromValue(0.0);
fadeInLotto.setToValue(1.0);
fadeInLotto.setCycleCount(1);
fadeInLotto.setAutoReverse(false);
this.btnImageSetting.setOnAction(this);
this.btnStart.setOnAction(this);
this.btnStop.setOnAction(this);
this.btnAddDraw.setOnAction(this);
this.btnChangeAdImage.setOnAction(this);
/*
this.imgAdvertising.setSmooth(true);
this.imgAdvertising.setCache(true);
this.imgAdvertising.setPreserveRatio(true);
*/
this.sldRotate.setValue(0);
this.sldScale.setValue(1);
this.anchorImageSettings.setVisible(false);
}
public类MainController实现可初始化的EventHandler
130MB不是那么多检查图像,使用率从50mb逐渐提高到1gbI,没有看到任何使用率峰值。您还说,byte[]
s使用130000000字节的内存,这是。。。130MB。@1BLASTONE请检查图像,我想知道为什么它有时会达到1GB,我的代码可能会出错。130MB的可能副本不是那么多。检查图像,使用率正在从50mb逐渐提高到1GB。没有看到任何使用率峰值。您还说,byte[]
s使用130000000字节的内存,这是。。。130MB。@1BLASTONE请检查图像,我想知道为什么它有时会达到1GB,我的代码可能会出错,可能是重复的