我正在使用java profiler测试我的应用程序。在Telemetry
配置文件下,我注意到它使用了太多的内存,我虽然这是我的项目中的类,所以我做了一个object
配置文件,并意识到它不是我的对象,实际上是最高的对象只消耗了6400B,然后我测试了我项目中的所有对象并且意识到byte[]
正在升级到130,000,000B
但是我的程序无所事事,什么都不做,我哪里出错了?这是我的JavaFx Main Class的一部分
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);
}
以下是内存使用If I leave the app for a longtime its shooting to up to a GB
的内容