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

JavaScript Memory Leak: #columnPreview click handlers #12058

Closed
jvilk opened this issue Sep 14, 2017 · 0 comments · Fixed by #12130
Closed

JavaScript Memory Leak: #columnPreview click handlers #12058

jvilk opened this issue Sep 14, 2017 · 0 comments · Fixed by #12130
Assignees
Labels
c: Performance For when we could improve the performance / speed of Matomo.

Comments

@jvilk
Copy link

jvilk commented Sep 14, 2017

renderDashboard adds click handlers to #columnPreview divs every time the user visits the dashboard, and never removes them:

https://github.com/piwik/piwik/blob/defc5469a5d4634d64023477a447a31c58812a12/plugins/Dashboard/angularjs/dashboard/dashboard.directive.js#L49

The result is a small memory leak.

Solution

A quick fix is to add the following just before you add the new listeners:

$('#columnPreview').find('>div').off('click');

If you are concerned about the possibility of there being other click handlers installed on the divs, you can namespace your handlers:

$('#columnPreview').find('>div').off('click.renderDashboard');
$('#columnPreview').find('>div').on('click.renderDashboard', ...);
@sgiehl sgiehl added the c: Performance For when we could improve the performance / speed of Matomo. label Sep 21, 2017
@sgiehl sgiehl self-assigned this Sep 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: Performance For when we could improve the performance / speed of Matomo.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants