From e29eb7e7e5542e29e321f7b256b93194d808ac22 Mon Sep 17 00:00:00 2001 From: Dima Sabanin Date: Tue, 4 Dec 2018 17:43:50 -0500 Subject: [PATCH] Fix memory leak / performance degradation On every re-render, ```update()``` method was calling ```this.append(list)```, that kept adding the widget to the MainPanel over and over again, without ever cleaning up. You could see it when moving back and forth through the log list, the more you moved, the slower it became. Cleaning up the list of children of MainPanel before re-adding the updated rows fixed the issue. --- src/widgets/MainPanel.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/widgets/MainPanel.js b/src/widgets/MainPanel.js index c302dd1..4da1dd6 100644 --- a/src/widgets/MainPanel.js +++ b/src/widgets/MainPanel.js @@ -507,6 +507,7 @@ class MainPanel extends BaseWidget { const content = formatRows( this.rows, columns, this.colSpacing, this.pageWidth-1).map(highlight).join('\n'); const list = blessed.element({ tags: true, content }); + this.children.forEach(child => this.remove(child)); this.append(list); this.screen.render(); if (notify) {