{"action":"opened","number":3439,"pull_request":{"url":"https://api.github.com/repos/dotnet/roslyn/pulls/3439","id":37430428,"html_url":"https://github.com/dotnet/roslyn/pull/3439","diff_url":"https://github.com/dotnet/roslyn/pull/3439.diff","patch_url":"https://github.com/dotnet/roslyn/pull/3439.patch","issue_url":"https://api.github.com/repos/dotnet/roslyn/issues/3439","number":3439,"state":"open","locked":false,"title":"Fix ITextBuffer leak after RenameTracking commit","user":{"login":"dpoeschl","id":235241,"avatar_url":"https://avatars.githubusercontent.com/u/235241?v=3","gravatar_id":"","url":"https://api.github.com/users/dpoeschl","html_url":"https://github.com/dpoeschl","followers_url":"https://api.github.com/users/dpoeschl/followers","following_url":"https://api.github.com/users/dpoeschl/following{/other_user}","gists_url":"https://api.github.com/users/dpoeschl/gists{/gist_id}","starred_url":"https://api.github.com/users/dpoeschl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dpoeschl/subscriptions","organizations_url":"https://api.github.com/users/dpoeschl/orgs","repos_url":"https://api.github.com/users/dpoeschl/repos","events_url":"https://api.github.com/users/dpoeschl/events{/privacy}","received_events_url":"https://api.github.com/users/dpoeschl/received_events","type":"User","site_admin":false},"body":"Fixes #830\r\n\r\nWhen a rename tracking session is committed, we create 4\r\nITextUndoPrimitives to facilitate the two-phase undo system that can\r\nclear or restore an earlier TrackingSession. These UndoPrimitives can\r\nlive beyond the lifetime of the buffer in which the TrackingSession\r\noccurred (when they are grouped into a global undo transaction), so it's\r\nimportant that they do not contain any strong references to the\r\nITextBuffer.\r\n\r\nThe UndoPrimitive class previously held a strong reference to the\r\nStateMachine, which directly referenced the ITextBuffer. Instead of\r\ndirectly referencing the StateMachine, the UndoPrimitive class now holds\r\na WeakReference to the ITextBuffer, from which we can retrieve the\r\nStateMachine (via its property bag). If the ITextBuffer has gone away\r\nbut the UndoPrimitive still exists as part of a global undo, then\r\nundo/redo will not be able to retrieve the StateMachine and will\r\ntherefore have no effect (as expected, because the only purpose of the\r\ncustom UndoPrimitives is to provide custom experiences in the\r\nITextBuffer that's already been GC'd).\r\n\r\nThe UndoPrimitive class also previously referenced the TrackingSession\r\nthat it needs to restore on undo, which then contains an ITrackingSpan\r\nthat references the ITextBuffer. Instead, the StateMachine itself now\r\nkeeps a list of all of the committed TrackingSessions, and the\r\nUndoPrimitive simply stores the index of it's target TrackingSpan into\r\nthat list. Because the StateMachine is only held alive in the\r\nITextBuffer's property bag, the StateMachine itself and all of the\r\npreviously committed TrackingSessions will be collected when the\r\nITextBuffer goes away.\r\n\r\nPotential Reviewers: @Pilchie @brettfo @jasonmalinowski @balajikris @rchande @basoundr @jmarolf","created_at":"2015-06-11T05:36:13Z","updated_at":"2015-06-11T05:36:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dotnet/roslyn/pulls/3439/commits","review_comments_url":"https://api.github.com/repos/dotnet/roslyn/pulls/3439/comments","review_comment_url":"https://api.github.com/repos/dotnet/roslyn/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/3439/comments","statuses_url":"https://api.github.com/repos/dotnet/roslyn/statuses/a581f9205a81519ecabd0b7fd78ebc7ee8a25081","head":{"label":"dpoeschl:RenameTrackingLeak","ref":"RenameTrackingLeak","sha":"a581f9205a81519ecabd0b7fd78ebc7ee8a25081","user":{"login":"dpoeschl","id":235241,"avatar_url":"https://avatars.githubusercontent.com/u/235241?v=3","gravatar_id":"","url":"https://api.github.com/users/dpoeschl","html_url":"https://github.com/dpoeschl","followers_url":"https://api.github.com/users/dpoeschl/followers","following_url":"https://api.github.com/users/dpoeschl/following{/other_user}","gists_url":"https://api.github.com/users/dpoeschl/gists{/gist_id}","starred_url":"https://api.github.com/users/dpoeschl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dpoeschl/subscriptions","organizations_url":"https://api.github.com/users/dpoeschl/orgs","repos_url":"https://api.github.com/users/dpoeschl/repos","events_url":"https://api.github.com/users/dpoeschl/events{/privacy}","received_events_url":"https://api.github.com/users/dpoeschl/received_events","type":"User","site_admin":false},"repo":{"id":30046829,"name":"roslyn","full_name":"dpoeschl/roslyn","owner":{"login":"dpoeschl","id":235241,"avatar_url":"https://avatars.githubusercontent.com/u/235241?v=3","gravatar_id":"","url":"https://api.github.com/users/dpoeschl","html_url":"https://github.com/dpoeschl","followers_url":"https://api.github.com/users/dpoeschl/followers","following_url":"https://api.github.com/users/dpoeschl/following{/other_user}","gists_url":"https://api.github.com/users/dpoeschl/gists{/gist_id}","starred_url":"https://api.github.com/users/dpoeschl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dpoeschl/subscriptions","organizations_url":"https://api.github.com/users/dpoeschl/orgs","repos_url":"https://api.github.com/users/dpoeschl/repos","events_url":"https://api.github.com/users/dpoeschl/events{/privacy}","received_events_url":"https://api.github.com/users/dpoeschl/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dpoeschl/roslyn","description":"The .NET Compiler Platform (\"Roslyn\") provides open-source C# and Visual Basic compilers with rich code analysis APIs.","fork":true,"url":"https://api.github.com/repos/dpoeschl/roslyn","forks_url":"https://api.github.com/repos/dpoeschl/roslyn/forks","keys_url":"https://api.github.com/repos/dpoeschl/roslyn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dpoeschl/roslyn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dpoeschl/roslyn/teams","hooks_url":"https://api.github.com/repos/dpoeschl/roslyn/hooks","issue_events_url":"https://api.github.com/repos/dpoeschl/roslyn/issues/events{/number}","events_url":"https://api.github.com/repos/dpoeschl/roslyn/events","assignees_url":"https://api.github.com/repos/dpoeschl/roslyn/assignees{/user}","branches_url":"https://api.github.com/repos/dpoeschl/roslyn/branches{/branch}","tags_url":"https://api.github.com/repos/dpoeschl/roslyn/tags","blobs_url":"https://api.github.com/repos/dpoeschl/roslyn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dpoeschl/roslyn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dpoeschl/roslyn/git/refs{/sha}","trees_url":"https://api.github.com/repos/dpoeschl/roslyn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dpoeschl/roslyn/statuses/{sha}","languages_url":"https://api.github.com/repos/dpoeschl/roslyn/languages","stargazers_url":"https://api.github.com/repos/dpoeschl/roslyn/stargazers","contributors_url":"https://api.github.com/repos/dpoeschl/roslyn/contributors","subscribers_url":"https://api.github.com/repos/dpoeschl/roslyn/subscribers","subscription_url":"https://api.github.com/repos/dpoeschl/roslyn/subscription","commits_url":"https://api.github.com/repos/dpoeschl/roslyn/commits{/sha}","git_commits_url":"https://api.github.com/repos/dpoeschl/roslyn/git/commits{/sha}","comments_url":"https://api.github.com/repos/dpoeschl/roslyn/comments{/number}","issue_comment_url":"https://api.github.com/repos/dpoeschl/roslyn/issues/comments{/number}","contents_url":"https://api.github.com/repos/dpoeschl/roslyn/contents/{+path}","compare_url":"https://api.github.com/repos/dpoeschl/roslyn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dpoeschl/roslyn/merges","archive_url":"https://api.github.com/repos/dpoeschl/roslyn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dpoeschl/roslyn/downloads","issues_url":"https://api.github.com/repos/dpoeschl/roslyn/issues{/number}","pulls_url":"https://api.github.com/repos/dpoeschl/roslyn/pulls{/number}","milestones_url":"https://api.github.com/repos/dpoeschl/roslyn/milestones{/number}","notifications_url":"https://api.github.com/repos/dpoeschl/roslyn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dpoeschl/roslyn/labels{/name}","releases_url":"https://api.github.com/repos/dpoeschl/roslyn/releases{/id}","created_at":"2015-01-29T23:37:29Z","updated_at":"2015-03-18T18:28:52Z","pushed_at":"2015-06-11T05:34:18Z","git_url":"git://github.com/dpoeschl/roslyn.git","ssh_url":"git@github.com:dpoeschl/roslyn.git","clone_url":"https://github.com/dpoeschl/roslyn.git","svn_url":"https://github.com/dpoeschl/roslyn","homepage":"","size":82945,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"dotnet:stabilization","ref":"stabilization","sha":"208574a0fd4f0fe94edf1cf74432e2952899cf85","user":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"repo":{"id":29078997,"name":"roslyn","full_name":"dotnet/roslyn","owner":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dotnet/roslyn","description":"The .NET Compiler Platform (\"Roslyn\") provides open-source C# and Visual Basic compilers with rich code analysis APIs.","fork":false,"url":"https://api.github.com/repos/dotnet/roslyn","forks_url":"https://api.github.com/repos/dotnet/roslyn/forks","keys_url":"https://api.github.com/repos/dotnet/roslyn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dotnet/roslyn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dotnet/roslyn/teams","hooks_url":"https://api.github.com/repos/dotnet/roslyn/hooks","issue_events_url":"https://api.github.com/repos/dotnet/roslyn/issues/events{/number}","events_url":"https://api.github.com/repos/dotnet/roslyn/events","assignees_url":"https://api.github.com/repos/dotnet/roslyn/assignees{/user}","branches_url":"https://api.github.com/repos/dotnet/roslyn/branches{/branch}","tags_url":"https://api.github.com/repos/dotnet/roslyn/tags","blobs_url":"https://api.github.com/repos/dotnet/roslyn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dotnet/roslyn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dotnet/roslyn/git/refs{/sha}","trees_url":"https://api.github.com/repos/dotnet/roslyn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dotnet/roslyn/statuses/{sha}","languages_url":"https://api.github.com/repos/dotnet/roslyn/languages","stargazers_url":"https://api.github.com/repos/dotnet/roslyn/stargazers","contributors_url":"https://api.github.com/repos/dotnet/roslyn/contributors","subscribers_url":"https://api.github.com/repos/dotnet/roslyn/subscribers","subscription_url":"https://api.github.com/repos/dotnet/roslyn/subscription","commits_url":"https://api.github.com/repos/dotnet/roslyn/commits{/sha}","git_commits_url":"https://api.github.com/repos/dotnet/roslyn/git/commits{/sha}","comments_url":"https://api.github.com/repos/dotnet/roslyn/comments{/number}","issue_comment_url":"https://api.github.com/repos/dotnet/roslyn/issues/comments{/number}","contents_url":"https://api.github.com/repos/dotnet/roslyn/contents/{+path}","compare_url":"https://api.github.com/repos/dotnet/roslyn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dotnet/roslyn/merges","archive_url":"https://api.github.com/repos/dotnet/roslyn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dotnet/roslyn/downloads","issues_url":"https://api.github.com/repos/dotnet/roslyn/issues{/number}","pulls_url":"https://api.github.com/repos/dotnet/roslyn/pulls{/number}","milestones_url":"https://api.github.com/repos/dotnet/roslyn/milestones{/number}","notifications_url":"https://api.github.com/repos/dotnet/roslyn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dotnet/roslyn/labels{/name}","releases_url":"https://api.github.com/repos/dotnet/roslyn/releases{/id}","created_at":"2015-01-11T02:39:03Z","updated_at":"2015-06-10T23:42:41Z","pushed_at":"2015-06-11T05:27:14Z","git_url":"git://github.com/dotnet/roslyn.git","ssh_url":"git@github.com:dotnet/roslyn.git","clone_url":"https://github.com/dotnet/roslyn.git","svn_url":"https://github.com/dotnet/roslyn","homepage":"","size":139874,"stargazers_count":2475,"watchers_count":2475,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":532,"mirror_url":null,"open_issues_count":942,"forks":532,"open_issues":942,"watchers":2475,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/3439"},"html":{"href":"https://github.com/dotnet/roslyn/pull/3439"},"issue":{"href":"https://api.github.com/repos/dotnet/roslyn/issues/3439"},"comments":{"href":"https://api.github.com/repos/dotnet/roslyn/issues/3439/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/3439/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/roslyn/pulls/3439/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/roslyn/statuses/a581f9205a81519ecabd0b7fd78ebc7ee8a25081"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":78,"deletions":24,"changed_files":3}}