{"action":"created","issue":{"url":"https://api.github.com/repos/RobotiumTech/robotium/issues/293","labels_url":"https://api.github.com/repos/RobotiumTech/robotium/issues/293/labels{/name}","comments_url":"https://api.github.com/repos/RobotiumTech/robotium/issues/293/comments","events_url":"https://api.github.com/repos/RobotiumTech/robotium/issues/293/events","html_url":"https://github.com/RobotiumTech/robotium/issues/293","id":101945212,"number":293,"title":"Memory leak when opening many activities in single test","user":{"login":"renas","id":165541,"avatar_url":"https://avatars.githubusercontent.com/u/165541?v=3","gravatar_id":"","url":"https://api.github.com/users/renas","html_url":"https://github.com/renas","followers_url":"https://api.github.com/users/renas/followers","following_url":"https://api.github.com/users/renas/following{/other_user}","gists_url":"https://api.github.com/users/renas/gists{/gist_id}","starred_url":"https://api.github.com/users/renas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/renas/subscriptions","organizations_url":"https://api.github.com/users/renas/orgs","repos_url":"https://api.github.com/users/renas/repos","events_url":"https://api.github.com/users/renas/events{/privacy}","received_events_url":"https://api.github.com/users/renas/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/RobotiumTech/robotium/labels/enhancement","name":"enhancement","color":"FFFFFF"},{"url":"https://api.github.com/repos/RobotiumTech/robotium/labels/imported","name":"imported","color":"FFFFFF"},{"url":"https://api.github.com/repos/RobotiumTech/robotium/labels/Priority-Medium","name":"Priority-Medium","color":"FFFFFF"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-08-19T16:52:30Z","updated_at":"2015-08-19T16:52:42Z","closed_at":null,"body":"_From [bjackson...@gmail.com](https://code.google.com/u/114193077724409504393/) on January 20, 2012 09:52:42_\n\n1. Run a test that loops and repeatedly opens and closes new activities\r\n2. Log output of Debug.getNativeHeapAllocatedSize() each time\r\n3. The memory used keeps increasing and will eventually crash the app\r\n\r\nThe ActivityUtils class has the LinkedHashSet<Activity> activityList member that keeps references to the closed activities. I tried adding in my loop a call to this new ActivityUtils method I threw together and the memory is gone.\r\n\r\n\tpublic void finishInactiveActivities() {\r\n\t\t// Finish all inactive activities\r\n\t\tfor (Iterator<Activity> iter = activityList.iterator(); iter.hasNext();) {\r\n\t\t\tActivity a = iter.next();\r\n\t\t\tif (a != getCurrentActivity()) {\r\n\t\t\t\tfinishActivity(a);\r\n\t\t\t\titer.remove();\r\n\t\t\t}\r\n\t\t}\r\n\t}\n\n_Original issue: http://code.google.com/p/robotium/issues/detail?id=214_"},"comment":{"url":"https://api.github.com/repos/RobotiumTech/robotium/issues/comments/132692874","html_url":"https://github.com/RobotiumTech/robotium/issues/293#issuecomment-132692874","issue_url":"https://api.github.com/repos/RobotiumTech/robotium/issues/293","id":132692874,"user":{"login":"renas","id":165541,"avatar_url":"https://avatars.githubusercontent.com/u/165541?v=3","gravatar_id":"","url":"https://api.github.com/users/renas","html_url":"https://github.com/renas","followers_url":"https://api.github.com/users/renas/followers","following_url":"https://api.github.com/users/renas/following{/other_user}","gists_url":"https://api.github.com/users/renas/gists{/gist_id}","starred_url":"https://api.github.com/users/renas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/renas/subscriptions","organizations_url":"https://api.github.com/users/renas/orgs","repos_url":"https://api.github.com/users/renas/repos","events_url":"https://api.github.com/users/renas/events{/privacy}","received_events_url":"https://api.github.com/users/renas/received_events","type":"User","site_admin":false},"created_at":"2015-08-19T16:52:42Z","updated_at":"2015-08-19T16:52:42Z","body":"_From [renasr...@gmail.com](https://code.google.com/u/108052454046732184536/) on January 22, 2012 23:22:16_\n\nThanks. This will be implemented in the next release.\n\n**Status:** Accepted  \n  **Owner:** renasr...@gmail.com  \n  **Labels:** -Type-Defect Type-Enhancement  \n"}}