Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory leak / performance degradation #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fix memory leak / performance degradation #13

wants to merge 1 commit into from

Conversation

dsabanin
Copy link

@dsabanin dsabanin commented Dec 4, 2018

On every re-render, update() method was calling this.append(list), that kept adding the rows widgets to the MainPanel over and over again, without ever cleaning up.

You could see the performance degradation when moving back and forth through the log list – the more you moved, the slower it became, to the point of unusability.

Cleaning up the list of children of MainPanel before re-adding the updated rows fixed the issue.

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.
@JakeH
Copy link

JakeH commented Dec 30, 2018

Very nice.

To add to your solution: Creating a new element each time is also a bit wasteful. Would be better to just use the built-in setContent method of the existing element and just omit the call to remove completely.

const [existing] = this.children.filter(o => o.type === 'element');
const list = existing || blessed.element({ tags: true });
list.setContent(content);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants