aurelia / router

A powerful client-side router.
MIT License
120 stars 115 forks source link

Memory Leak in router / di #614

Closed fragsalat closed 6 years ago

fragsalat commented 6 years ago

I'm submitting a bug report

Please tell us about your environment:

Current behavior: Custom elements are not cleaned up by the garbage collector because the router / container doesn't release the references. Therefore every time the page is shown a new instance of the custom element is rendered. An example path looks like instruction.viewPortInstructions.default.controller.view.controllers[0].viewModel = CustomElement

Expected/desired behavior: Custom elements should be de-referenced when calling unbind or deactivate so that the garbage collector can clean them up regardless how many times I navigate back and forward.

Helpful: I prepared and tested based on a clean aurelia cli setup and just submitting everything. I uploaded the project here https://github.com/fragsalat/demos/tree/master/aurelia-memory-leak

How to reproduce:

I hope you know what would be a good solution. In my application several custom elements have a big tree and every page reload around 3mb are added to the heap^^

3cp commented 6 years ago

I am no expert of this, but I think I can reproduce the issue, seeing JS Heap keep growing.

fragsalat commented 6 years ago

@EisenbergEffect @davismj ping

PS: @EisenbergEffect it would be nice to have a maintainers file in each repo to know who's responsible and to not ping you for every issue :D

EisenbergEffect commented 6 years ago

This is a good idea. @davismj is it ok if I list your GitHub alias as lead for this repo with @bigopon as a second?

EisenbergEffect commented 6 years ago

For vNext, we'll probably be able to take advantage of protected branches and code owners better as well. In both cases, we can document the primary contacts though.

fragsalat commented 6 years ago

I actually could find out that the cause of the memory leak is bluebird and not the router. Bluebird holds the navigationInstructions in a CaptureTrace object which is not cleared up.

davismj commented 6 years ago

@EisenbergEffect Yes, of course.

@fragsalat Thanks for the update! Appreciate the follow up.

3cp commented 6 years ago

@fragsalat do you have a bug report to bluebird? or do you have some work around in aurelia app? Since majority of aurelia apps use bluebird, this could affect many users.

fragsalat commented 5 years ago

I just removed Bluebird as I don't need and like it anyway^^ Sry I've not searched for another solution.