Out of memory exception when loading a solution (in v0.7.0 it worked).
I have a quite large solution which I automatically refactor using roslyn to migrate ASMX Web Services to WCF. Till now I did it using version 0.7.0 of ROslyn, now I switched to 1.0.0-rc2 and solution stopped loading, OpenSolutionAsync ends with OutOfMemoryException after consuming 1.63GB. On v0.7.0 solution loads eating ~74MB. Something went terribly wrong between releases.
Call Stack is as follows:
System.AggregateException: One or more errors occurred. ---> System.OutOfMemoryException: Insufficient memory to continue the execution of the program.
at System.Runtime.InteropServices.Marshal.AllocHGlobal(IntPtr cb)
at System.Reflection.Internal.StreamMemoryBlockProvider.ReadMemoryBlockNoLock(Stream stream, Boolean isFileStream, Int64 start, Int32 size)
at System.Reflection.PortableExecutable.PEReader..ctor(Stream peStream, PEStreamOptions options, Nullable1 sizeOpt) at Microsoft.CodeAnalysis.ModuleMetadata.CreateFromStream(Stream peStream, PEStreamOptions options) at Microsoft.CodeAnalysis.MetadataReference.CreateFromFile(String path, MetadataReferenceProperties properties, DocumentationProvider documentation) at Microsoft.CodeAnalysis.Host.MetadataServiceFactory.Provider.GetReference(String resolvedPath, MetadataReferenceProperties properties) at Microsoft.CodeAnalysis.AssemblyReferenceResolver.ResolveReference(String reference, String baseFilePath, MetadataReferenceProperties properties) at Microsoft.CodeAnalysis.CommandLineArguments.ResolveMetadataReference(CommandLineReference cmdReference, MetadataReferenceResolver metadataResolver, List1 diagnosticsOpt, CommonMessageProvider messageProviderOpt)
at Microsoft.CodeAnalysis.CommandLineArguments.ResolveMetadataReferences(MetadataReferenceResolver metadataResolver, List1 diagnosticsOpt, CommonMessageProvider messageProviderOpt, List1 resolved)
at Microsoft.CodeAnalysis.CommandLineArguments.ResolveMetadataReferences(MetadataReferenceResolver metadataResolver)
at Microsoft.CodeAnalysis.CSharp.CSharpProjectFileLoader.CSharpProjectFile.GetReferences(CSharpCompilerInputs compilerInputs, ProjectInstance executedProject, IEnumerable1& metadataReferences, IEnumerable1& analyzerReferences)
at Microsoft.CodeAnalysis.CSharp.CSharpProjectFileLoader.CSharpProjectFile.CreateProjectFileInfo(CSharpCompilerInputs compilerInputs, ProjectInstance executedProject)
at Microsoft.CodeAnalysis.CSharp.CSharpProjectFileLoader.CSharpProjectFile.1.GetResultCore(Boolean waitCompletionNotification) at System.Threading.Tasks.Task1.get_Result()
@jasonmalinowski @mattwar Did one of you recently look at a leak in MSBuildWorkspace?
I didn't. @xprzemekw, when it crashes, are you able to make a full memory dump of the process at that point? Then we could take a look at what's causing the leak if you have somewhere to upload it. But it'll be a ~2.0 GB file so if that's unworkable or a huge pain then that's fine.
@jasonmalinowski I have created a dump and 7zipped it, it is avilable here: https://github.com/xprzemekw/misc/blob/master/MemoryDump.7z
BTW: In 64bits world processing completes eating ~3.2GB.
So this doesn't look like a leak of any MSBuild structures itself -- I see lots of objects in memory but most of them are unrooted. @xprzemekw's stack though might actually be pointing to the problem instead of an unlucky victim though: there's several thousand ModuleMetadatas in memory. Assuming your solution isn't referencing 2000 unique DLLs (seems unlikely :smile:), there must be some broken cache somewhere.
@Pilchie, it looks like we need a cache here. Quickly adding one wouldn't be too terribly difficult. Want to reconsider the milestone?
I was able to build an app that opens Roslyn.sln using MSBuildWorkspace and get diagnostics on every project in the solution, and memory stayed around 1GB.