{"action":"created","issue":{"url":"https://api.github.com/repos/phetsims/vegas/issues/52","repository_url":"https://api.github.com/repos/phetsims/vegas","labels_url":"https://api.github.com/repos/phetsims/vegas/issues/52/labels{/name}","comments_url":"https://api.github.com/repos/phetsims/vegas/issues/52/comments","events_url":"https://api.github.com/repos/phetsims/vegas/issues/52/events","html_url":"https://github.com/phetsims/vegas/issues/52","id":146441095,"number":52,"title":"reward node had no dispose function, leaks memory","user":{"login":"jbphet","id":3082831,"avatar_url":"https://avatars.githubusercontent.com/u/3082831?v=3","gravatar_id":"","url":"https://api.github.com/users/jbphet","html_url":"https://github.com/jbphet","followers_url":"https://api.github.com/users/jbphet/followers","following_url":"https://api.github.com/users/jbphet/following{/other_user}","gists_url":"https://api.github.com/users/jbphet/gists{/gist_id}","starred_url":"https://api.github.com/users/jbphet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbphet/subscriptions","organizations_url":"https://api.github.com/users/jbphet/orgs","repos_url":"https://api.github.com/users/jbphet/repos","events_url":"https://api.github.com/users/jbphet/events{/privacy}","received_events_url":"https://api.github.com/users/jbphet/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"aadish","id":4546788,"avatar_url":"https://avatars.githubusercontent.com/u/4546788?v=3","gravatar_id":"","url":"https://api.github.com/users/aadish","html_url":"https://github.com/aadish","followers_url":"https://api.github.com/users/aadish/followers","following_url":"https://api.github.com/users/aadish/following{/other_user}","gists_url":"https://api.github.com/users/aadish/gists{/gist_id}","starred_url":"https://api.github.com/users/aadish/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aadish/subscriptions","organizations_url":"https://api.github.com/users/aadish/orgs","repos_url":"https://api.github.com/users/aadish/repos","events_url":"https://api.github.com/users/aadish/events{/privacy}","received_events_url":"https://api.github.com/users/aadish/received_events","type":"User","site_admin":false},"milestone":null,"comments":3,"created_at":"2016-04-06T21:29:30Z","updated_at":"2016-04-07T18:24:08Z","closed_at":null,"body":"While inspecting code changes for https://github.com/phetsims/build-an-atom/issues/101, I noticed that no dispose function was being called on ```BAARewardNode```, which is a sub-type of the common code type ```RewardNode```.  I did some testing and found that reward nodes are not being garbage collected, see the screenshot of a heap profile below.  In this profile, I'd gotten the reward node three times, and all three are still around.  Since the reward node often creates a lot of sub-nodes, it is fairly memory intensive, and in this profile it's consuming a little more than 2% of all memory for the sim.\r\n![reward-node-mem-leak](https://cloud.githubusercontent.com/assets/3082831/14333446/eee4e20a-fc0b-11e5-80a1-6f3af4b9c1ea.PNG)\r\nAs an experiment, I commented out the two lines of code in the following excerpt from the ```RewardNode``` and the leak went away.\r\n```js\r\n        // When the scene is resized, update the bounds\r\n        scene.addEventListener( 'resize', updateBounds );\r\n\r\n        // When the ScreenView transform changes, update the bounds.  This prevents a \"behind by one\" problem, see https://github.com/phetsims/vegas/issues/4\r\n        this.getScreenView().on( 'transform', updateBounds );\r\n```\r\nA dispose function should probably be added that removes these listeners.\r\n"},"comment":{"url":"https://api.github.com/repos/phetsims/vegas/issues/comments/207037188","html_url":"https://github.com/phetsims/vegas/issues/52#issuecomment-207037188","issue_url":"https://api.github.com/repos/phetsims/vegas/issues/52","id":207037188,"user":{"login":"jbphet","id":3082831,"avatar_url":"https://avatars.githubusercontent.com/u/3082831?v=3","gravatar_id":"","url":"https://api.github.com/users/jbphet","html_url":"https://github.com/jbphet","followers_url":"https://api.github.com/users/jbphet/followers","following_url":"https://api.github.com/users/jbphet/following{/other_user}","gists_url":"https://api.github.com/users/jbphet/gists{/gist_id}","starred_url":"https://api.github.com/users/jbphet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbphet/subscriptions","organizations_url":"https://api.github.com/users/jbphet/orgs","repos_url":"https://api.github.com/users/jbphet/repos","events_url":"https://api.github.com/users/jbphet/events{/privacy}","received_events_url":"https://api.github.com/users/jbphet/received_events","type":"User","site_admin":false},"created_at":"2016-04-07T18:24:08Z","updated_at":"2016-04-07T18:24:08Z","body":"Note that the 3rd item in @samreid's list above may need to be done in *all* simulations where RewardNode is used."}}