{"action":"created","issue":{"url":"https://api.github.com/repos/NativeScript/nativescript-angular/issues/1658","repository_url":"https://api.github.com/repos/NativeScript/nativescript-angular","labels_url":"https://api.github.com/repos/NativeScript/nativescript-angular/issues/1658/labels{/name}","comments_url":"https://api.github.com/repos/NativeScript/nativescript-angular/issues/1658/comments","events_url":"https://api.github.com/repos/NativeScript/nativescript-angular/issues/1658/events","html_url":"https://github.com/NativeScript/nativescript-angular/issues/1658","id":389056740,"node_id":"MDU6SXNzdWUzODkwNTY3NDA=","number":1658,"title":"Page router outlet memory leak","user":{"login":"KkevinLi","id":14020249,"node_id":"MDQ6VXNlcjE0MDIwMjQ5","avatar_url":"https://avatars1.githubusercontent.com/u/14020249?v=4","gravatar_id":"","url":"https://api.github.com/users/KkevinLi","html_url":"https://github.com/KkevinLi","followers_url":"https://api.github.com/users/KkevinLi/followers","following_url":"https://api.github.com/users/KkevinLi/following{/other_user}","gists_url":"https://api.github.com/users/KkevinLi/gists{/gist_id}","starred_url":"https://api.github.com/users/KkevinLi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KkevinLi/subscriptions","organizations_url":"https://api.github.com/users/KkevinLi/orgs","repos_url":"https://api.github.com/users/KkevinLi/repos","events_url":"https://api.github.com/users/KkevinLi/events{/privacy}","received_events_url":"https://api.github.com/users/KkevinLi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-12-09T19:45:48Z","updated_at":"2018-12-12T12:19:23Z","closed_at":null,"author_association":"NONE","body":"**Environment**\r\nProvide version numbers for the following components (information can be retrieved by running `tns info` in your project folder or by inspecting the `package.json` of the project):\r\n```✔ Getting NativeScript components versions information...\r\n⚠ Update available for component nativescript. Your current version is 5.0.1 and the latest available version is 5.0.3.\r\n✔ Component tns-core-modules has 5.2.0-2018-11-29-161511-02 version and is up to date.\r\n⚠ Update available for component tns-android. Your current version is 5.0.0-rc-2018-10-26-162351-01 and the latest available version is 5.0.0.\r\n✔ Component tns-ios has 5.0.0 version and is up to date.\r\n```\r\n \r\n**Describe the bug**\r\n<!-- A clear and concise description of what the bug is. Please, explain whether it's a build time error or a runtime error. More detailed logs can be easily obtained by following the instructions in this guide: https://docs.nativescript.org/get-support#how-to-obtain-diagnostic-reports. -->\r\n\r\nI am noticing that forward navigations never release the memory and eventually I will run out of memory and my app will crash. This is happening even with clearHistory = true. Calling gc.__collect() did not free up the memory either.\r\n\r\nIn this sample project the pages are pretty empty so the increase takes a bit of time, but in production with more content on a page the memory increase is very noticeable. \r\n\r\n(Starts at around 80mb. The sharp increase in the beginning is navigating often between \"Go To Welcome and Logout\". As we navigate around the simple app you can see the memory allocation keeps increasing.)\r\n\r\n\r\n<img width=\"872\" alt=\"screen shot 2018-12-10 at 9 55 42 am\" src=\"https://user-images.githubusercontent.com/14020249/49740245-d0ce2c00-fc61-11e8-9443-aede8b8d4912.png\">\r\n\r\n\r\n\r\n**To Reproduce**\r\n<!-- Add commands used or steps taken to reproduce the behaviour. -->\r\nUsing that sample project which explains nested routers, if you just hit \"Go to welcome page\" and then \"logout\" a few times you can see using instruments that the memory allocation keeps increasing. \r\n\r\n**Expected behavior**\r\n\r\nNavigating between pages with clearHistory should be restoring us to the initial memory usage.\r\n\r\n**Sample project**\r\n<!-- If possible, provide a link from the [Playground](https://play.nativescript.org) with reproduction of the problem. If not, consider attaching a sample project or link to a repository with such project. -->\r\nhttps://github.com/ADjenkov/login-tabs-ng"},"comment":{"url":"https://api.github.com/repos/NativeScript/nativescript-angular/issues/comments/446568454","html_url":"https://github.com/NativeScript/nativescript-angular/issues/1658#issuecomment-446568454","issue_url":"https://api.github.com/repos/NativeScript/nativescript-angular/issues/1658","id":446568454,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0NjU2ODQ1NA==","user":{"login":"tsonevn","id":17448734,"node_id":"MDQ6VXNlcjE3NDQ4NzM0","avatar_url":"https://avatars3.githubusercontent.com/u/17448734?v=4","gravatar_id":"","url":"https://api.github.com/users/tsonevn","html_url":"https://github.com/tsonevn","followers_url":"https://api.github.com/users/tsonevn/followers","following_url":"https://api.github.com/users/tsonevn/following{/other_user}","gists_url":"https://api.github.com/users/tsonevn/gists{/gist_id}","starred_url":"https://api.github.com/users/tsonevn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tsonevn/subscriptions","organizations_url":"https://api.github.com/users/tsonevn/orgs","repos_url":"https://api.github.com/users/tsonevn/repos","events_url":"https://api.github.com/users/tsonevn/events{/privacy}","received_events_url":"https://api.github.com/users/tsonevn/received_events","type":"User","site_admin":false},"created_at":"2018-12-12T12:19:23Z","updated_at":"2018-12-12T12:19:23Z","author_association":"CONTRIBUTOR","body":"Hi @KkevinLi,\r\nI have tested the described scenario with the login-tabs-ng project, however, was unable to recreate a crash. I have noticed that in the project, that you have mentioned, are used some old dependencies. I would suggest updating then. Check out the attached sample `package.json`.\r\n```\r\n{\r\n  \"description\": \"NativeScript Application\",\r\n  \"license\": \"SEE LICENSE IN <your-license-filename>\",\r\n  \"readme\": \"NativeScript Application\",\r\n  \"repository\": \"<fill-your-repository-here>\",\r\n  \"nativescript\": {\r\n    \"id\": \"org.nativescript.testapp\",\r\n    \"tns-ios\": {\r\n      \"version\": \"5.0.0\"\r\n    }\r\n  },\r\n  \"dependencies\": {\r\n    \"@angular/animations\": \"~7.0.0\",\r\n    \"@angular/common\": \"~7.0.0\",\r\n    \"@angular/compiler\": \"~7.0.0\",\r\n    \"@angular/core\": \"~7.0.0\",\r\n    \"@angular/forms\": \"~7.0.0\",\r\n    \"@angular/http\": \"~7.0.0\",\r\n    \"@angular/platform-browser\": \"~7.0.0\",\r\n    \"@angular/platform-browser-dynamic\": \"~7.0.0\",\r\n    \"@angular/router\": \"~7.0.0\",\r\n    \"nativescript-angular\": \"~7.0.0\",\r\n    \"nativescript-theme-core\": \"~1.0.4\",\r\n    \"reflect-metadata\": \"~0.1.10\",\r\n    \"rxjs\": \"~6.1.0\",\r\n    \"tns-core-modules\": \"^5.0.5\",\r\n    \"zone.js\": \"~0.8.18\"\r\n  },\r\n  \"devDependencies\": {\r\n    \"nativescript-dev-typescript\": \"~0.7.0\",\r\n    \"nativescript-dev-webpack\": \"~0.12.0\",\r\n    \"typescript\": \"~2.7.2\",\r\n    \"webpack\": \"~4.6.0\",\r\n    \"webpack-cli\": \"~2.1.3\",\r\n    \"webpack-bundle-analyzer\": \"~2.13.0\",\r\n    \"webpack-sources\": \"~1.1.0\",\r\n    \"clean-webpack-plugin\": \"~0.1.19\",\r\n    \"copy-webpack-plugin\": \"~4.5.1\",\r\n    \"raw-loader\": \"~0.5.1\",\r\n    \"css-loader\": \"~0.28.11\",\r\n    \"nativescript-worker-loader\": \"~0.9.0\",\r\n    \"extract-text-webpack-plugin\": \"~3.0.2\",\r\n    \"uglifyjs-webpack-plugin\": \"~1.2.5\",\r\n    \"@angular/compiler-cli\": \"~7.0.0\",\r\n    \"@ngtools/webpack\": \"~6.0.3\",\r\n    \"@angular-devkit/core\": \"~0.6.3\",\r\n    \"resolve-url-loader\": \"~2.3.0\"\r\n  }\r\n}\r\n```\r\nKeep in mind that the garbage collection will not be triggered immediately when you make navigation with a clear history. The GC will be called when the OS required it. You can check the post here, where it is described the [memory management](https://panayotcankov.github.io/nativescript-3.2.0-memory-management/) in NativeScript. You can check the attached image from `instruments`, generated while testing the case. You can notice that the memory is released at some intervals. The result is based on 630 navigations.\r\n\r\n![screen shot 2018-12-12 at 2 17 32 pm](https://user-images.githubusercontent.com/17448734/49869315-c1451380-fe18-11e8-92a1-c840b47c94dd.png)\r\n\r\nIt will help if you can send us your app, which will allow us to investigate further the crash, you are facing and what exactly is causing it."}}
{"actor":{"display_login":"tsonevn"}}