{"action":"created","issue":{"url":"https://api.github.com/repos/angular/angular/issues/20007","repository_url":"https://api.github.com/repos/angular/angular","labels_url":"https://api.github.com/repos/angular/angular/issues/20007/labels{/name}","comments_url":"https://api.github.com/repos/angular/angular/issues/20007/comments","events_url":"https://api.github.com/repos/angular/angular/issues/20007/events","html_url":"https://github.com/angular/angular/issues/20007","id":269444659,"node_id":"MDU6SXNzdWUyNjk0NDQ2NTk=","number":20007,"title":"Memory leak when FormControlName created/destroyed few times","user":{"login":"IliaVolk","id":15018651,"node_id":"MDQ6VXNlcjE1MDE4NjUx","avatar_url":"https://avatars2.githubusercontent.com/u/15018651?v=4","gravatar_id":"","url":"https://api.github.com/users/IliaVolk","html_url":"https://github.com/IliaVolk","followers_url":"https://api.github.com/users/IliaVolk/followers","following_url":"https://api.github.com/users/IliaVolk/following{/other_user}","gists_url":"https://api.github.com/users/IliaVolk/gists{/gist_id}","starred_url":"https://api.github.com/users/IliaVolk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IliaVolk/subscriptions","organizations_url":"https://api.github.com/users/IliaVolk/orgs","repos_url":"https://api.github.com/users/IliaVolk/repos","events_url":"https://api.github.com/users/IliaVolk/events{/privacy}","received_events_url":"https://api.github.com/users/IliaVolk/received_events","type":"User","site_admin":false},"labels":[{"id":393879365,"node_id":"MDU6TGFiZWwzOTM4NzkzNjU=","url":"https://api.github.com/repos/angular/angular/labels/comp:%20forms","name":"comp: forms","color":"c5def5","default":false},{"id":375497160,"node_id":"MDU6TGFiZWwzNzU0OTcxNjA=","url":"https://api.github.com/repos/angular/angular/labels/freq2:%20medium","name":"freq2: medium","color":"fbca04","default":false},{"id":375498062,"node_id":"MDU6TGFiZWwzNzU0OTgwNjI=","url":"https://api.github.com/repos/angular/angular/labels/severity4:%20memleak","name":"severity4: memleak","color":"0052cc","default":false},{"id":130606843,"node_id":"MDU6TGFiZWwxMzA2MDY4NDM=","url":"https://api.github.com/repos/angular/angular/labels/type:%20bug/fix","name":"type: bug/fix","color":"EEEEEE","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/angular/angular/milestones/82","html_url":"https://github.com/angular/angular/milestone/82","labels_url":"https://api.github.com/repos/angular/angular/milestones/82/labels","id":3045967,"node_id":"MDk6TWlsZXN0b25lMzA0NTk2Nw==","number":82,"title":"Backlog","description":"Milestone for triaged issues that have not yet been scheduled for resolution.","creator":{"login":"IgorMinar","id":216296,"node_id":"MDQ6VXNlcjIxNjI5Ng==","avatar_url":"https://avatars3.githubusercontent.com/u/216296?v=4","gravatar_id":"","url":"https://api.github.com/users/IgorMinar","html_url":"https://github.com/IgorMinar","followers_url":"https://api.github.com/users/IgorMinar/followers","following_url":"https://api.github.com/users/IgorMinar/following{/other_user}","gists_url":"https://api.github.com/users/IgorMinar/gists{/gist_id}","starred_url":"https://api.github.com/users/IgorMinar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IgorMinar/subscriptions","organizations_url":"https://api.github.com/users/IgorMinar/orgs","repos_url":"https://api.github.com/users/IgorMinar/repos","events_url":"https://api.github.com/users/IgorMinar/events{/privacy}","received_events_url":"https://api.github.com/users/IgorMinar/received_events","type":"User","site_admin":false},"open_issues":1929,"closed_issues":369,"state":"open","created_at":"2018-01-18T16:52:20Z","updated_at":"2018-09-26T09:00:02Z","due_on":null,"closed_at":null},"comments":7,"created_at":"2017-10-29T22:44:48Z","updated_at":"2018-09-26T09:13:21Z","closed_at":null,"author_association":"NONE","body":"<!--\r\nPLEASE HELP US PROCESS GITHUB ISSUES FASTER BY PROVIDING THE FOLLOWING INFORMATION.\r\n\r\nISSUES MISSING IMPORTANT INFORMATION MAY BE CLOSED WITHOUT INVESTIGATION.\r\n-->\r\n\r\n## I'm submitting a...\r\n<!-- Check one of the following options with \"x\" -->\r\n<pre><code>\r\n[ ] Regression (a behavior that used to work and stopped working in a new release)\r\n[x] Bug report  <!-- Please search GitHub for a similar issue or PR before submitting -->\r\n[ ] Feature request\r\n[ ] Documentation issue or request\r\n[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question\r\n</code></pre>\r\n\r\n## Current behavior\r\n<!-- Describe how the issue manifests. -->\r\n1. FormControlName, objects provided by NG_VALIDATORS (may be some other) can not be collected by gc until there are refs for FormGroup.\r\nThis is caused by collecting closures created in https://github.com/angular/angular/blob/4.4.6/packages/forms/src/directives/shared.ts#L33  in https://github.com/angular/angular/blob/4.4.6/packages/forms/src/model.ts#L744 .\r\n2. All provided validators (via NG_VALIDATORS token) are called as many times as form is recreated.\r\n\r\n## Expected behavior\r\n1. After destroying FormControlName it should be collected by gc even if there are refs for FormGroup.\r\n2. Provided validators should be removed from FormControl after destroying FormControlName.\r\n\r\n## Minimal reproduction of the problem with instructions\r\nhttps://plnkr.co/edit/eCtf2naoxLe8bWTJ8IkV?p=preview (used example from material demo as starting point)\r\n\r\n#### Steps to reproduce\r\n1. show/hide form clicking checkbox.\r\n2. displayed below number of listeners is increasing.\r\n3. there are more and more messages 'Validate called' appears in console when editing input (In my project I had issue when validators set outdated errors, had to use workaround).\r\n\r\n\r\nThere are 3 inputs to show that they are not synchronized (Is there a significant reason to store all closures, not only last?).\r\n<!--\r\nFor bug reports please provide the *STEPS TO REPRODUCE* and if possible a *MINIMAL DEMO* of the problem via\r\nhttps://plnkr.co or similar (you can use this template as a starting point: http://plnkr.co/edit/tpl:AvJOMERrnz94ekVua0u5).\r\n-->\r\n\r\n## What is the motivation/use case for changing the behavior?\r\n<!-- Describe the motivation or the concrete use case. -->\r\n1. Allow to have permanent FormControl/FormGroup without memory leaks.\r\n2. Allow to dynamically create FormControlName with custom control, which knows how to validate itself (providing NG_VALIDATORS), without calling validators of destroyed controls.\r\n## Environment\r\n\r\n<pre><code>\r\nAngular version: 4.4.6\r\n<!-- Check whether this is still an issue in the most recent Angular version -->\r\n\r\nBrowser:\r\n- [x] Chrome (desktop) version 62.0.3202.75\r\n- [ ] Chrome (Android) version XX\r\n- [ ] Chrome (iOS) version XX\r\n- [ ] Firefox version XX\r\n- [ ] Safari (desktop) version XX\r\n- [ ] Safari (iOS) version XX\r\n- [ ] IE version XX\r\n- [ ] Edge version XX\r\n \r\nOthers:\r\n<!-- Anything else relevant?  Operating system version, IDE, package manager, HTTP server, ... -->\r\n</code></pre>\r\n"},"comment":{"url":"https://api.github.com/repos/angular/angular/issues/comments/424644217","html_url":"https://github.com/angular/angular/issues/20007#issuecomment-424644217","issue_url":"https://api.github.com/repos/angular/angular/issues/20007","id":424644217,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNDY0NDIxNw==","user":{"login":"pengx17","id":584378,"node_id":"MDQ6VXNlcjU4NDM3OA==","avatar_url":"https://avatars1.githubusercontent.com/u/584378?v=4","gravatar_id":"","url":"https://api.github.com/users/pengx17","html_url":"https://github.com/pengx17","followers_url":"https://api.github.com/users/pengx17/followers","following_url":"https://api.github.com/users/pengx17/following{/other_user}","gists_url":"https://api.github.com/users/pengx17/gists{/gist_id}","starred_url":"https://api.github.com/users/pengx17/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pengx17/subscriptions","organizations_url":"https://api.github.com/users/pengx17/orgs","repos_url":"https://api.github.com/users/pengx17/repos","events_url":"https://api.github.com/users/pengx17/events{/privacy}","received_events_url":"https://api.github.com/users/pengx17/received_events","type":"User","site_admin":false},"created_at":"2018-09-26T09:13:21Z","updated_at":"2018-09-26T09:13:21Z","author_association":"NONE","body":"The plunker example is dead. Here is a minimized stackblitz version:\r\nhttps://stackblitz.com/edit/angular-jr5cds?file=src%2Fapp%2Fcontrol.component.html\r\n\r\nThe workaround we can come up with for now is to use hidden attribute instead of ngIf for the snippet of form to enforce stabilized structure of the reactive formgroup."}}
{"actor":{"display_login":"pengx17"}}