{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/5482","labels_url":"https://api.github.com/repos/dotnet/roslyn/issues/5482/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/5482/comments","events_url":"https://api.github.com/repos/dotnet/roslyn/issues/5482/events","html_url":"https://github.com/dotnet/roslyn/issues/5482","id":108673755,"number":5482,"title":"Memory usage of roslyn","user":{"login":"overeemm","id":915800,"avatar_url":"https://avatars.githubusercontent.com/u/915800?v=3","gravatar_id":"","url":"https://api.github.com/users/overeemm","html_url":"https://github.com/overeemm","followers_url":"https://api.github.com/users/overeemm/followers","following_url":"https://api.github.com/users/overeemm/following{/other_user}","gists_url":"https://api.github.com/users/overeemm/gists{/gist_id}","starred_url":"https://api.github.com/users/overeemm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/overeemm/subscriptions","organizations_url":"https://api.github.com/users/overeemm/orgs","repos_url":"https://api.github.com/users/overeemm/repos","events_url":"https://api.github.com/users/overeemm/events{/privacy}","received_events_url":"https://api.github.com/users/overeemm/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dotnet/roslyn/labels/Area-Compilers","name":"Area-Compilers","color":"5319e7"},{"url":"https://api.github.com/repos/dotnet/roslyn/labels/Bug","name":"Bug","color":"fc2929"},{"url":"https://api.github.com/repos/dotnet/roslyn/labels/Question","name":"Question","color":"fc2929"},{"url":"https://api.github.com/repos/dotnet/roslyn/labels/Tenet-Performance","name":"Tenet-Performance","color":"eb6420"}],"state":"open","locked":false,"assignee":{"login":"KevinH-MS","id":6464209,"avatar_url":"https://avatars.githubusercontent.com/u/6464209?v=3","gravatar_id":"","url":"https://api.github.com/users/KevinH-MS","html_url":"https://github.com/KevinH-MS","followers_url":"https://api.github.com/users/KevinH-MS/followers","following_url":"https://api.github.com/users/KevinH-MS/following{/other_user}","gists_url":"https://api.github.com/users/KevinH-MS/gists{/gist_id}","starred_url":"https://api.github.com/users/KevinH-MS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KevinH-MS/subscriptions","organizations_url":"https://api.github.com/users/KevinH-MS/orgs","repos_url":"https://api.github.com/users/KevinH-MS/repos","events_url":"https://api.github.com/users/KevinH-MS/events{/privacy}","received_events_url":"https://api.github.com/users/KevinH-MS/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/dotnet/roslyn/milestones/11","html_url":"https://github.com/dotnet/roslyn/milestones/2.0","labels_url":"https://api.github.com/repos/dotnet/roslyn/milestones/11/labels","id":1109349,"number":11,"title":"2.0","description":"The next major version.","creator":{"login":"gafter","id":3804346,"avatar_url":"https://avatars.githubusercontent.com/u/3804346?v=3","gravatar_id":"","url":"https://api.github.com/users/gafter","html_url":"https://github.com/gafter","followers_url":"https://api.github.com/users/gafter/followers","following_url":"https://api.github.com/users/gafter/following{/other_user}","gists_url":"https://api.github.com/users/gafter/gists{/gist_id}","starred_url":"https://api.github.com/users/gafter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gafter/subscriptions","organizations_url":"https://api.github.com/users/gafter/orgs","repos_url":"https://api.github.com/users/gafter/repos","events_url":"https://api.github.com/users/gafter/events{/privacy}","received_events_url":"https://api.github.com/users/gafter/received_events","type":"User","site_admin":false},"open_issues":130,"closed_issues":5,"state":"open","created_at":"2015-05-13T22:28:30Z","updated_at":"2015-12-01T00:08:12Z","due_on":null,"closed_at":null},"comments":1,"created_at":"2015-09-28T14:50:08Z","updated_at":"2015-12-01T05:09:59Z","closed_at":null,"body":"I'm using the following snippet to produce dll's from in-memory strings (representing C# files). \r\n\r\n    CSharpCompilation compilation = CSharpCompilation.Create(assemblyName,\r\n        syntaxTrees: trees,\r\n        references: references,\r\n        options: new CSharpCompilationOptions(\r\n          OutputKind.DynamicallyLinkedLibrary,\r\n          optimizationLevel: OptimizationLevel.Debug\r\n          )\r\n        );\r\n\r\n      EmitResult result = compilation.Emit(outputDllPath, pdbPath: $\"{Path.ChangeExtension(outputDllPath, \"pdb\")}\");\r\n\r\nAfter this code has run, I use the memory profiler (the vs2015 one) to look at the heap. I see that lot's of Roslyn related files are sticking around (mainly objects from Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.*).\r\n\r\nIs there a way to prevent this? And should I try to prevent this, or is there caching involved that improves the speed of compiling? I've done some testing with doing the parsing and compiling in a separate appdomain for every dll. This helps in garbage collection, but it seems wrong."},"comment":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/comments/160854297","html_url":"https://github.com/dotnet/roslyn/issues/5482#issuecomment-160854297","issue_url":"https://api.github.com/repos/dotnet/roslyn/issues/5482","id":160854297,"user":{"login":"KevinH-MS","id":6464209,"avatar_url":"https://avatars.githubusercontent.com/u/6464209?v=3","gravatar_id":"","url":"https://api.github.com/users/KevinH-MS","html_url":"https://github.com/KevinH-MS","followers_url":"https://api.github.com/users/KevinH-MS/followers","following_url":"https://api.github.com/users/KevinH-MS/following{/other_user}","gists_url":"https://api.github.com/users/KevinH-MS/gists{/gist_id}","starred_url":"https://api.github.com/users/KevinH-MS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KevinH-MS/subscriptions","organizations_url":"https://api.github.com/users/KevinH-MS/orgs","repos_url":"https://api.github.com/users/KevinH-MS/repos","events_url":"https://api.github.com/users/KevinH-MS/events{/privacy}","received_events_url":"https://api.github.com/users/KevinH-MS/received_events","type":"User","site_admin":false},"created_at":"2015-12-01T05:09:59Z","updated_at":"2015-12-01T05:09:59Z","body":"I do not *believe* there are any static caches in the compiler that would result in this behavior.\r\n\r\nIt seems most likely that your program is holding on to his “trees” object or the  “compilation” object that is getting created.  If you null those out after calling Emit, I would expect things to get GC’ed eventually.\r\n"}}