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

Minor JavaScript Memory Leak: `piwikApiService` `allRequests` array #12105

Closed
jvilk opened this Issue Sep 22, 2017 · 2 comments

Comments

Projects
None yet
3 participants
@jvilk
Contributor

jvilk commented Sep 22, 2017

Problem

The piwikApiService class contains an array called allRequests that it appends to whenever the frontend makes an API request. However, it only clears this array if abortAll is called. Over a session with the Piwik dashboard, the array continues to grow as the frontend makes API requests.

Solution

allRequests should only contain active requests that have not yet completed, as it is only used by abortAll.

A simple solution is to remove requests when they complete. To do this, change line 170 to the following:

allRequests.push(request);
promise.finally(function() {
  var index = allRequests.indexOf(request);
  if (index !== -1) {
    allRequests.splice(index, 1);
  }
});
@tsteur

This comment has been minimized.

Show comment
Hide comment
@tsteur

tsteur Sep 23, 2017

Member

Great suggestion. Do you mind issuing a pull request for this?

Member

tsteur commented Sep 23, 2017

Great suggestion. Do you mind issuing a pull request for this?

jvilk pushed a commit to jvilk/piwik that referenced this issue Nov 2, 2017

jvilk pushed a commit to jvilk/piwik that referenced this issue Nov 8, 2017

@jvilk

This comment has been minimized.

Show comment
Hide comment
@jvilk

jvilk Nov 9, 2017

Contributor

PR issued and awaiting review!

Contributor

jvilk commented Nov 9, 2017

PR issued and awaiting review!

tsteur added a commit that referenced this issue Dec 14, 2017

@mattab mattab added the duplicate label Jan 12, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment