{"action":"created","issue":{"url":"https://api.github.com/repos/robolectric/robolectric/issues/1724","labels_url":"https://api.github.com/repos/robolectric/robolectric/issues/1724/labels{/name}","comments_url":"https://api.github.com/repos/robolectric/robolectric/issues/1724/comments","events_url":"https://api.github.com/repos/robolectric/robolectric/issues/1724/events","html_url":"https://github.com/robolectric/robolectric/pull/1724","id":70562817,"number":1724,"title":"Fix for permgen leak","user":{"login":"jongerrish","id":6314616,"avatar_url":"https://avatars.githubusercontent.com/u/6314616?v=3","gravatar_id":"","url":"https://api.github.com/users/jongerrish","html_url":"https://github.com/jongerrish","followers_url":"https://api.github.com/users/jongerrish/followers","following_url":"https://api.github.com/users/jongerrish/following{/other_user}","gists_url":"https://api.github.com/users/jongerrish/gists{/gist_id}","starred_url":"https://api.github.com/users/jongerrish/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jongerrish/subscriptions","organizations_url":"https://api.github.com/users/jongerrish/orgs","repos_url":"https://api.github.com/users/jongerrish/repos","events_url":"https://api.github.com/users/jongerrish/events{/privacy}","received_events_url":"https://api.github.com/users/jongerrish/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-04-24T02:12:09Z","updated_at":"2015-04-28T06:12:21Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/robolectric/robolectric/pulls/1724","html_url":"https://github.com/robolectric/robolectric/pull/1724","diff_url":"https://github.com/robolectric/robolectric/pull/1724.diff","patch_url":"https://github.com/robolectric/robolectric/pull/1724.patch"},"body":"I think this should fix https://github.com/robolectric/robolectric/issues/1700\r\n\r\nI profiled Robolectric's own test suite and noticed that we were creating and holding onto 17 SdkEnvironment objects, each of which has an InstrumentingClassloader referenced.\r\n\r\nI think we want just a single SdkEnvironment+InstrumentingClassloader per SdkConfig for the whole VM.\r\n\r\nI think the root cause was the circular references of RobolectricTestRunner -> lastTestRunnerClass when each test runner instance has a reference to both the current and last sdk config.\r\n\r\nWith this fix applied the perm gen peaks at ~150MB where as without the fix peaks at ~250MB - heap seems unaffected.\r\n\r\n![without_fix_permgen](https://cloud.githubusercontent.com/assets/6314616/7311068/d1884626-e9eb-11e4-9535-38cf2c88477a.png)\r\n![with_fix_heap](https://cloud.githubusercontent.com/assets/6314616/7311069/d1a993f8-e9eb-11e4-8e2d-ce601d403a09.png)\r\n![with_fix_permgen](https://cloud.githubusercontent.com/assets/6314616/7311071/d49da216-e9eb-11e4-9a0c-0df8e3f5e4e7.png)\r\n![without_fix_heap](https://cloud.githubusercontent.com/assets/6314616/7311072/d5fcc2fe-e9eb-11e4-86e6-ab90e614f298.png)\r\n"},"comment":{"url":"https://api.github.com/repos/robolectric/robolectric/issues/comments/96935661","html_url":"https://github.com/robolectric/robolectric/pull/1724#issuecomment-96935661","issue_url":"https://api.github.com/repos/robolectric/robolectric/issues/1724","id":96935661,"user":{"login":"kageiit","id":291148,"avatar_url":"https://avatars.githubusercontent.com/u/291148?v=3","gravatar_id":"","url":"https://api.github.com/users/kageiit","html_url":"https://github.com/kageiit","followers_url":"https://api.github.com/users/kageiit/followers","following_url":"https://api.github.com/users/kageiit/following{/other_user}","gists_url":"https://api.github.com/users/kageiit/gists{/gist_id}","starred_url":"https://api.github.com/users/kageiit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kageiit/subscriptions","organizations_url":"https://api.github.com/users/kageiit/orgs","repos_url":"https://api.github.com/users/kageiit/repos","events_url":"https://api.github.com/users/kageiit/events{/privacy}","received_events_url":"https://api.github.com/users/kageiit/received_events","type":"User","site_admin":false},"created_at":"2015-04-28T06:12:21Z","updated_at":"2015-04-28T06:12:21Z","body":"Would be great to test this out once it makes it to snapshot."}}