Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Datepicker leaks memory when used in presence of jquery #2658

Closed
ankit5990 opened this issue Sep 3, 2014 · 7 comments
Closed

Datepicker leaks memory when used in presence of jquery #2658

ankit5990 opened this issue Sep 3, 2014 · 7 comments

Comments

@ankit5990
Copy link
Contributor

When datepicker is used in an application which has jQuery included as well, then datepicker is seen to leak memory.

The scope of the controller on which datepicker is used is seen to leak when an investigation of heap is done.

I have created a plunker to show this issue.
http://embed.plnkr.co/qRZEMgBRNIBRjE1fTcCM/
On repeatedly opening and closing a page with datepicker on it, leaks memory which is never reclaimed on GC cycle.
screenshot 2014-09-03 19 04 17

@cyrilwiz
Copy link

cyrilwiz commented Sep 4, 2014

+1

1 similar comment
@karora23
Copy link

karora23 commented Sep 4, 2014

+1

@chrisirhc
Copy link
Contributor

Thanks for posting this. I've done some investigation to this. It looks like an AngularJS bug with jQuery's cache. It's jQuery's caching that's keeping the references to the scopes. The newest AngularJs version seems to have fixed most of the leaking.

Your Plunker (Angular 1.2.10):
screen shot 2014-09-03 at 11 48 22 pm

Angular 1.3.0-beta.14:
screen shot 2014-09-03 at 11 42 16 pm

Angular 1.3.0-rc.0:
screen shot 2014-09-03 at 11 43 02 pm

Notice there are differences in the y-axis scaling, but look at the "Selected Size" value.

Here's the Plunker I used:
http://plnkr.co/edit/MupMyWCj4oMUonz5EMA7?p=preview

@suyash1208
Copy link

+1

1 similar comment
@ashishgoyal86
Copy link

+1

@ankit5990
Copy link
Contributor Author

I have made the fix in the code for this issue. Its a very small fix, datepickerPopup directive creates a popupElement div in the code which needed to be removed. I have created plunkers for comparison.

Plunk without fix:-
http://embed.plnkr.co/CYV8uXKv1O7ODkFroee4/

Plunk after fix:-
http://embed.plnkr.co/buFTsQp7TMsbNRlKXTKf/preview

Memory usage before fix-
before fix

Memory usage after fix-
after fix

I would like to contribute the change back to the library. @chrisirhc can you help me on how to submit a PR?

@ankit5990
Copy link
Contributor Author

Created a pull request for the fix
#2684

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants