Datepicker Memory Leak
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 11.3k
- Forks
- 5.2k
- PR merge metrics
- No merged PRs in 30d
Description
Building off #2268, there is a problem when destroying the datepicker where it doesn’t completely get removed from memory. This pull request, https://github.com/jquery/jquery-ui/commit/817ce38, removes the instance reference but the actual UI reference is tied to
When the widget is destroyed, the datepicker UI element remains in memory preventing it from closing. https://github.com/jquery/jquery-ui/pull/2268 patches this issue by hiding the component, however dpDiv is still in memory. One solution could be to remove dpDiv from the instance and then set both _curInst = null and this.dpDiv = null.
https://github.com/jquery/jquery-ui/pull/2268/commits/5e4f1b86296c5a977abc7efaff671ea9004d4d37
However, many unit tests will break because they rely on dpDiv to still exist in memory, requiring the datepicker to be recreated for each test. There is also a problem that many developers rely on hiding the datepicker before destroying it $.datepicker("hide").destroy("destroy") which will fail because dpDiv will be null.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Inspect ui/widgets/datepicker.js around line 163 and trace the destroy path described in the issue. Review the unit tests that rely on dpDiv and reproduce the hide-then-destroy sequence. Done means the datepicker UI is no longer retained after destruction while the affected tests and documented usage behavior are addressed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, jquery
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100