1

I was testing my application using java profiler. Under the Telemetry profile I noticed It was using way too much memory, I though it was my classes in my project so i did a object profile and realized it was not my objects, in fact the highest object only consumed 6400B, then I tested all the objects in my project and realized byte[] was going up to 130,000,000B but my program is idle doing absolutely nothing, where am I going wrong? here is a part of my 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);
 }

Here is a snipshot of the memory use If I leave the app for a longtime its shooting to up to a GB

Memory usage by objects

Rando roxford
  • 141
  • 2
  • 10

0 Answers0