{"action":"created","issue":{"url":"https://api.github.com/repos/angular/material/issues/11493","repository_url":"https://api.github.com/repos/angular/material","labels_url":"https://api.github.com/repos/angular/material/issues/11493/labels{/name}","comments_url":"https://api.github.com/repos/angular/material/issues/11493/comments","events_url":"https://api.github.com/repos/angular/material/issues/11493/events","html_url":"https://github.com/angular/material/issues/11493","id":373188169,"node_id":"MDU6SXNzdWUzNzMxODgxNjk=","number":11493,"title":"dialog: memory leak when injecting $mdDialog","user":{"login":"kimtuck","id":3791539,"node_id":"MDQ6VXNlcjM3OTE1Mzk=","avatar_url":"https://avatars2.githubusercontent.com/u/3791539?v=4","gravatar_id":"","url":"https://api.github.com/users/kimtuck","html_url":"https://github.com/kimtuck","followers_url":"https://api.github.com/users/kimtuck/followers","following_url":"https://api.github.com/users/kimtuck/following{/other_user}","gists_url":"https://api.github.com/users/kimtuck/gists{/gist_id}","starred_url":"https://api.github.com/users/kimtuck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kimtuck/subscriptions","organizations_url":"https://api.github.com/users/kimtuck/orgs","repos_url":"https://api.github.com/users/kimtuck/repos","events_url":"https://api.github.com/users/kimtuck/events{/privacy}","received_events_url":"https://api.github.com/users/kimtuck/received_events","type":"User","site_admin":false},"labels":[{"id":310906949,"node_id":"MDU6TGFiZWwzMTA5MDY5NDk=","url":"https://api.github.com/repos/angular/material/labels/P1:%20urgent","name":"P1: urgent","color":"d93f0b","default":false},{"id":235114695,"node_id":"MDU6TGFiZWwyMzUxMTQ2OTU=","url":"https://api.github.com/repos/angular/material/labels/needs:%20Pull%20Request","name":"needs: Pull Request","color":"02d7e1","default":false},{"id":235109221,"node_id":"MDU6TGFiZWwyMzUxMDkyMjE=","url":"https://api.github.com/repos/angular/material/labels/needs:%20investigation","name":"needs: investigation","color":"444444","default":false},{"id":235117473,"node_id":"MDU6TGFiZWwyMzUxMTc0NzM=","url":"https://api.github.com/repos/angular/material/labels/severity:%20performance","name":"severity: performance","color":"fb6420","default":false},{"id":183019810,"node_id":"MDU6TGFiZWwxODMwMTk4MTA=","url":"https://api.github.com/repos/angular/material/labels/type:%20performance","name":"type: performance","color":"0052cc","default":false}],"state":"open","locked":false,"assignee":{"login":"Splaktar","id":3506071,"node_id":"MDQ6VXNlcjM1MDYwNzE=","avatar_url":"https://avatars1.githubusercontent.com/u/3506071?v=4","gravatar_id":"","url":"https://api.github.com/users/Splaktar","html_url":"https://github.com/Splaktar","followers_url":"https://api.github.com/users/Splaktar/followers","following_url":"https://api.github.com/users/Splaktar/following{/other_user}","gists_url":"https://api.github.com/users/Splaktar/gists{/gist_id}","starred_url":"https://api.github.com/users/Splaktar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Splaktar/subscriptions","organizations_url":"https://api.github.com/users/Splaktar/orgs","repos_url":"https://api.github.com/users/Splaktar/repos","events_url":"https://api.github.com/users/Splaktar/events{/privacy}","received_events_url":"https://api.github.com/users/Splaktar/received_events","type":"User","site_admin":false},"assignees":[{"login":"Splaktar","id":3506071,"node_id":"MDQ6VXNlcjM1MDYwNzE=","avatar_url":"https://avatars1.githubusercontent.com/u/3506071?v=4","gravatar_id":"","url":"https://api.github.com/users/Splaktar","html_url":"https://github.com/Splaktar","followers_url":"https://api.github.com/users/Splaktar/followers","following_url":"https://api.github.com/users/Splaktar/following{/other_user}","gists_url":"https://api.github.com/users/Splaktar/gists{/gist_id}","starred_url":"https://api.github.com/users/Splaktar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Splaktar/subscriptions","organizations_url":"https://api.github.com/users/Splaktar/orgs","repos_url":"https://api.github.com/users/Splaktar/repos","events_url":"https://api.github.com/users/Splaktar/events{/privacy}","received_events_url":"https://api.github.com/users/Splaktar/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/angular/material/milestones/65","html_url":"https://github.com/angular/material/milestone/65","labels_url":"https://api.github.com/repos/angular/material/milestones/65/labels","id":3621818,"node_id":"MDk6TWlsZXN0b25lMzYyMTgxOA==","number":65,"title":"1.1.12","description":"This is the last planned \"patch\" release before the team shifts focus to the 1.2.0 \"minor\" release. \"patch\" release with bug fixes, docs updates, and features, but no breaking changes (layout, css, APIs, etc)","creator":{"login":"Splaktar","id":3506071,"node_id":"MDQ6VXNlcjM1MDYwNzE=","avatar_url":"https://avatars1.githubusercontent.com/u/3506071?v=4","gravatar_id":"","url":"https://api.github.com/users/Splaktar","html_url":"https://github.com/Splaktar","followers_url":"https://api.github.com/users/Splaktar/followers","following_url":"https://api.github.com/users/Splaktar/following{/other_user}","gists_url":"https://api.github.com/users/Splaktar/gists{/gist_id}","starred_url":"https://api.github.com/users/Splaktar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Splaktar/subscriptions","organizations_url":"https://api.github.com/users/Splaktar/orgs","repos_url":"https://api.github.com/users/Splaktar/repos","events_url":"https://api.github.com/users/Splaktar/events{/privacy}","received_events_url":"https://api.github.com/users/Splaktar/received_events","type":"User","site_admin":false},"open_issues":128,"closed_issues":0,"state":"open","created_at":"2018-09-04T18:12:21Z","updated_at":"2018-10-25T11:38:36Z","due_on":"2018-12-07T08:00:00Z","closed_at":null},"comments":2,"created_at":"2018-10-23T20:31:04Z","updated_at":"2018-10-25T20:36:44Z","closed_at":null,"author_association":"NONE","body":"## Bug:\r\n\r\n<!-- Please note that we are not accepting major feature requests, i.e. requests for new components, at this time. -->\r\n\r\nhttps://codepen.io/kimtuck/pen/yRRbjb\r\n\r\n#### Detailed Reproduction Steps: \r\n \r\n1. Run the contents of the pen using karma.  Monitor the memory usage of chrome while the tests are running.  You will see the memory creep up dramatically, until around 2.1GB chrome crashes.\r\n\r\n### What is the expected behavior?\r\nMemory remains more or less constant, because all we're doing here is injecting `$mdDialog`, which is a service (a singleton).\r\n\r\n### What is the current behavior?\r\nMemory is dramatically consumed\r\n\r\n### What is the use-case or motivation for changing an existing behavior?\r\nMemory leak will lead to application crashes or poor performance.  In a set of unit tests that inject `$mdDialog` in many places (as our application does) chrome crashes during the unit test run, leading to a failed unit test.\r\n\r\n### Which versions of AngularJS, Material, OS, and browsers are affected?\r\nSee the package.json in the codepen.  Relevant lines from package.json:\r\n    \"angular\": \"^1.7.2\",\r\n    \"angular-animate\": \"^1.7.2\",\r\n    \"angular-aria\": \"^1.7.2\",\r\n    \"angular-messages\": \"^1.7.2\",\r\n    \"angular-material\": \"^1.1.10\",\r\n- OS: windows 10\r\n- Browsers: Chrome\r\n \r\n### Is there anything else we should know? Stack Traces, Screenshots, etc.\r\n\r\nThis is the (partial) code for MdDialogProvider.  If you remove the `.setDefaults()` and the `.addPresets()` then there is no memory leak.  If you include the `.setDefaults()` and remove the `.addPresets()` then the memory leak occurs.\r\n\r\nSo, the memory leak is in the `.setDefaults()` call.  \r\n\r\nNote that on each test invocation, the MdDialogProvider method executes; and thus the `setDefaults()` method runs on each test invocation.\r\n```js\r\nfunction MdDialogProvider($$interimElementProvider) {\r\n  // Elements to capture and redirect focus when the user presses tab at the dialog boundary.\r\n  MdDialogController['$inject'] = [\"$mdDialog\", \"$mdConstant\"];\r\n  dialogDefaultOptions['$inject'] = [\"$mdDialog\", \"$mdAria\", \"$mdUtil\", \"$mdConstant\", \"$animate\", \"$document\", \"$window\", \"$rootElement\", \"$log\", \"$injector\", \"$mdTheming\", \"$interpolate\", \"$mdInteraction\"];\r\n  var topFocusTrap, bottomFocusTrap;\r\n\r\n  return $$interimElementProvider('$mdDialog')\r\n    .setDefaults({\r\n      methods: ['disableParentScroll', 'hasBackdrop', 'clickOutsideToClose', 'escapeToClose',\r\n          'targetEvent', 'closeTo', 'openFrom', 'parent', 'fullscreen', 'multiple'],\r\n      options: dialogDefaultOptions\r\n    })\r\n    .addPreset('alert', {\r\n      methods: ['title', 'htmlContent', 'textContent', 'content', 'ariaLabel', 'ok', 'theme',\r\n          'css'],\r\n      options: advancedDialogOptions\r\n    })\r\n    .addPreset('confirm', {\r\n      methods: ['title', 'htmlContent', 'textContent', 'content', 'ariaLabel', 'ok', 'cancel',\r\n          'theme', 'css'],\r\n      options: advancedDialogOptions\r\n    })\r\n    .addPreset('prompt', {\r\n      methods: ['title', 'htmlContent', 'textContent', 'initialValue', 'content', 'placeholder', 'ariaLabel',\r\n          'ok', 'cancel', 'theme', 'css', 'required'],\r\n      options: advancedDialogOptions\r\n    });\r\n```"},"comment":{"url":"https://api.github.com/repos/angular/material/issues/comments/433196724","html_url":"https://github.com/angular/material/issues/11493#issuecomment-433196724","issue_url":"https://api.github.com/repos/angular/material/issues/11493","id":433196724,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMzE5NjcyNA==","user":{"login":"Splaktar","id":3506071,"node_id":"MDQ6VXNlcjM1MDYwNzE=","avatar_url":"https://avatars1.githubusercontent.com/u/3506071?v=4","gravatar_id":"","url":"https://api.github.com/users/Splaktar","html_url":"https://github.com/Splaktar","followers_url":"https://api.github.com/users/Splaktar/followers","following_url":"https://api.github.com/users/Splaktar/following{/other_user}","gists_url":"https://api.github.com/users/Splaktar/gists{/gist_id}","starred_url":"https://api.github.com/users/Splaktar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Splaktar/subscriptions","organizations_url":"https://api.github.com/users/Splaktar/orgs","repos_url":"https://api.github.com/users/Splaktar/repos","events_url":"https://api.github.com/users/Splaktar/events{/privacy}","received_events_url":"https://api.github.com/users/Splaktar/received_events","type":"User","site_admin":false},"created_at":"2018-10-25T20:36:44Z","updated_at":"2018-10-25T20:36:44Z","author_association":"MEMBER","body":"I only said that it \"looks like a duplicate\". I didn't say that it was a duplicate and I didn't close it as a duplicate. But thank you for your clarification.\r\n\r\nhttps://github.com/angular/material/issues/11024#issuecomment-427118139 also reports a memory leak where `md-button` is used and `$mdDialog` is injected but never used. I'll do some re-testing of things after we get one of these fixed to see how it affects the others."}}
{"actor":{"display_login":"Splaktar"}}