You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
There is a memory leak which occurs if the table config isFixed and because of that inside the DataTable init method the resize event listener is added to the DOM window object.
Proof of concept:
The DataTable is created and will be added again by pressing the load icon, which keeps the "old" DataTable in a detached state because of the listener and the garbage collector isn't able to remove it.
The usecase for adding a new DataTable to the card is to add columns after the data itself is refreshed, this is not part of the PoC
To Reproduce
public class Poc implements EntryPoint {
private LocalListDataStore<DataObject> localListDataStore;
private DataTable<DataObject> table;
private final TableConfig<DataObject> tableConfig = new TableConfig<>();
private final Card card = Card.create();
@Override
public void onModuleLoad() {
Layout layout = Layout.create("PoC").show(ColorScheme.BLUE);
tableConfig.setFixed(true);
tableConfig.addColumn(ColumnConfig.<DataObject>create("Index", "Index")
.setCellRenderer(cell -> TextNode.of(cell.getTableRow().getRecord().column1)));
localListDataStore = new LocalListDataStore<>();
table = new DataTable<>(tableConfig, localListDataStore);
List<DataObject> data = new ArrayList<>();
for (int i = 0; i <= 5; i++) {
data.add(new DataObject(i, "Test"));
}
card.addHeaderAction(new HeaderAction(Icons.MDI_ICONS.refresh_mdi()).addClickListener((Event evt) -> {
card.getBody().clearElement();
localListDataStore = new LocalListDataStore<>();
table = new DataTable<>(tableConfig, localListDataStore);
card.appendChild(table);
localListDataStore.setData(data);
}));
card.appendChild(table);
layout.getContentPanel().appendChild(card);
}
private static class DataObject {
Integer index;
String column1;
public DataObject(Integer index, String column1) {
this.index = index;
this.column1 = column1;
}
}
}
Expected behavior
No memory leak ;-)
Screenshots
State after several "loads"
Desktop (please complete the following information):
All
Smartphone (please complete the following information):
All
Additional context
The text was updated successfully, but these errors were encountered:
Describe the bug
There is a memory leak which occurs if the table config isFixed and because of that inside the DataTable init method the resize event listener is added to the DOM window object.
Proof of concept:
The DataTable is created and will be added again by pressing the load icon, which keeps the "old" DataTable in a detached state because of the listener and the garbage collector isn't able to remove it.
The usecase for adding a new DataTable to the card is to add columns after the data itself is refreshed, this is not part of the PoC
To Reproduce
Expected behavior
No memory leak ;-)
Screenshots
![grafik](https://user-images.githubusercontent.com/74547492/172824205-0f928143-d39e-422a-801d-940f5b9f97b6.png)
State after several "loads"
Desktop (please complete the following information):
All
Smartphone (please complete the following information):
All
Additional context
The text was updated successfully, but these errors were encountered: