JavaFx Table View Memory leakages

465 Views Asked by At

I have created table View in JavaFx 2x,It's has more than 10K rows and each row has 20 columns, Whenever table view is loading java heap old gen memory is increasing and it's not releasing. After loading the same table for 2-3 times(refresh button and every time before loading the table clearing all the references mentioned below). My Application is freezing or goes to not responding state, I have tried have all the options clear the references form memory but no luck

  @FXML
        private TableView<PersonModel> personlicense;

        private void initTable(){
                    licState
                                .setCellValueFactory(new Callback<TableColumn.CellDataFeatures<PersonModel, String>, ObservableValue<String>>() {

                                    @Override
                                    public ObservableValue<String> call(
                                            final CellDataFeatures<PersonModel, String> cdf) {
                                        return cdf.getValue().iconStateProperty();
                                    }
                                });

                        colCompliance
                                .setCellValueFactory(new Callback<TableColumn.CellDataFeatures<PersonModel, String>, ObservableValue<String>>() {

                                    @Override
                                    public ObservableValue<String> call(
                                            final CellDataFeatures<PersonModel, String> cdf) {
                                        return cdf.getValue().complianceDetailStrProperty();
                                    }
                        });
        }
        priavte void populate(){
                final ObservableList<PersonModel> itemsMultiTable = personlicense.getItems();
                    if (!itemsMultiTable.isEmpty()) {
                                itemsMultiTable.removeAll(itemsMultiTable);
                                clean();
                    }
                    for (final Person personObj : selectedPersons) {                    
                                final PersonModel LicModel = personObj.getLicense();
                                itemsMultiTable.add(LicModel);
                    }

        }
     private void clean(){
        Class tcb=TableCellBehavior.class;
            try{
                Method anchormethod=tcb.getDeclaredMethod("setAnchor",TableView.class,TablePosition.class);
                anchormethod.setAccessible(true);
                anchormethod.invoke(null,resumeTable,null);
            }
            catch(Throwable t){
                throw new RuntimeException(t);
            }
            personlicense.setFocusModel(null);
            personlicense.setOnMouseClicked(null);
            personlicense.setSelectionModel(null);
            personlicense.getColumns().clear();
            personlicense.getItems().clear();
    }

I had seen some posts in this forum are suggesting to upgrade to java8, but my client is not willing to upgrade

is there any possible solution to release the memory...?

MAT Analysis is below MAT analysis report

Thank you

0

There are 0 best solutions below