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
Memory leak (Detached Dom Trees) #193
Comments
The below piece can take a performance hit $scope.task = data
} I would process data first before attach to $scope. |
I had a similar experience using |
I also have a similar issue and opened a stakoverflow question here and a jsfiddle to demonstrate the issue. Basicaly, I'm doing some cleanup on the $destroy event of the controller and on the routeChange event, but it seems we need more than that:
|
@Pi-r- setting the chart and graph data to empty values did not work for me. I believe it is not garbage collected since the data is still somehow referenced in the html. I tested my environment with the google profiler (comparing the heap snapshots). The following code does not leak the SVG elements. But still the Array data is somehow leaked: $rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams) {
angular.element(document.body.querySelectorAll('.nvd3')).remove(); My leak reduced from 5 MB to 2 MB. |
Hi,
I am creating a webapp where the users can access to certain line charts. These line charts are organized in different routes. The issue that I have is that, it seems that, after visiting one of this charts, once the user has moved to a different route, the memory used to display the chart is not released. So if the user keeps visiting different charts for a while, or even if the user just keeps visiting the same chart, the webapp ends up consuming all the memory available in the system.
Using the profile tool in the Chrome Dev Tools, I have seen that there are "Detached Dom Tree" elements in my app that contain stuff like "SVGCircleElement", "SVGSVGElement", "SVGLineElement". Do I have to listen for $destroy() in order to somehow manually delete this elements?
I am quite new to Angularjs and js in general, so probably there is some bug somewhere in my app. But I have already made the app as simple as possible and still cannot find how to avoid this issue.
I just have a module like:
With a controller:
I fetch the data:
And I store the pairs of "key" + "values" in an array (each page can have multiple line charts). Something like:
And then I display the charts:
Has anybody experienced a similar problem? Any hint about what could be going wrong?
Thanks a lot for your help!
The text was updated successfully, but these errors were encountered: