Skip to content

Minor JavaScript Memory Leak: piwikApiService allRequests array #12105

@jvilk

Description

@jvilk

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);
  }
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugFor errors / faults / flaws / inconsistencies etc.c: PerformanceFor when we could improve the performance / speed of Matomo.duplicateFor issues that already existed in our issue tracker and were reported previously.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions