I have a JavaFX TableView that dynamically changes column properties (width, visibility) to implement a few "custom column settings / presets".
I noticed a huge amount of memory without memory when I change the column settings. I tried to reproduce the situation using simple Java code and was able to do this with the attached program:
NOTE: After starting the program, everything is in order! Memory is collected as expected. Things seem terrible as soon as we click on the TableMenuButton (plus sign) to the right of the column heading. It grows endlessly to an OutOfMemoryError.

public class TableViewMenuButtonLeak extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) {
final TableView<Record> table = new TableView<>();
table.setTableMenuButtonVisible(true);
for(int i = 0; i < 4; i++) {
TableColumn<Record, String> column1 = new TableColumn<>("column"+i);
column1.setCellValueFactory(new PropertyValueFactory<Record, String>("column"+i));
table.getColumns().add(column1);
}
Runnable r = () -> {
while(true) {
Platform.runLater(() -> {
table.getColumns().stream().forEach((c) -> c.setPrefWidth(Math.random() * 300));
table.getColumns().stream().forEach((c) -> c.setVisible(Math.random() > 0.5 ? true : false));
});
try {
Thread.sleep(1);
} catch (InterruptedException e) {}
}
};
Thread t = new Thread(r);
t.setDaemon(true);
t.start();
stage.setTitle("!!!! Do click onto the \"TableMenuButton\" on the right side of the table (PLUS sign) !!!");
Scene scene = new Scene(table);
stage.setWidth(600);
stage.setHeight(600);
stage.setScene(scene);
stage.show();
}
public static class Record {
private final StringProperty column1;
private final StringProperty column2;
public Record(String column1, String column2) {
this.column1 = new SimpleStringProperty(column1);
this.column2 = new SimpleStringProperty(column2);
}
public String getColumn1() {
return column1.get();
}
public StringProperty column1Property() {
return column1;
}
public String getColumn2() {
return column2.get();
}
public StringProperty column2Property() {
return column2;
}
}
}
,
"StackPane", "ContextMenuContent $MenuLabel" "ContextMenuContent $MenuItemContainer".
:
JDK 1_8_ (60/91/102). !