0

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

  • What method are you using to load the data? What is the data model class? Do you have any custom cell factories? You are basically asking us to debug your application without providing any code. – Itai Jun 28 '17 at 09:19
  • Updated the post – user3351400 Jun 28 '17 at 10:40
  • Do you know which class or classes is responsible for the leak? Try using a profiler such as JVisualVM to see which class, if any, gets progressively more instances with each refresh. See e.g. this question: https://stackoverflow.com/questions/9154785/how-to-find-memory-leaks-using-visualvm – Itai Jun 28 '17 at 10:58
  • I don't know this tool, and it's hard to read a static image with cropped graphs, but it looks like the `TableView` object is only 91MB, with some other object(s?) taking 816MB. Which one is that? What does the "leak suspects" report show? – Itai Jul 03 '17 at 07:40

0 Answers0