Skip to content

OutOfMemoryException (lots of large winforms designer files) #850

@sanketgroup

Description

@sanketgroup

Steps to reproduce

  1. I downloaded and installed latest version 8.4.6.0 from https://marketplace.visualstudio.com/
  2. I opened my VB.net project in VS2019 and right-clicked "Convert to C#". The project has around 1200 VB forms including designer forms. Phase 1 was completed after 7 hours with having one error in one form.
  3. Phase 2 started, after around 40 forms I got the following error.

Error message shown

https://github.com/dotnet/roslyn threw an exception: System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
   at System.Runtime.CompilerServices.ConditionalWeakTable`2.Resize()
   at System.Runtime.CompilerServices.ConditionalWeakTable`2.CreateEntry(TKey key, TValue value)
   at System.Runtime.CompilerServices.ConditionalWeakTable`2.Add(TKey key, TValue value)
   at Microsoft.CodeAnalysis.GreenNode..ctor(ObjectReader reader)
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.MemberAccessExpressionSyntax..ctor(ObjectReader reader)
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.MemberAccessExpressionSyntax.<>c.<.cctor>b__21_0(ObjectReader r)
   at Roslyn.Utilities.ObjectReader.ReadObject()
   at Roslyn.Utilities.ObjectReader.ReadValueWorker()
   at Roslyn.Utilities.ObjectReader.ReadValue()
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.CastExpressionSyntax..ctor(ObjectReader reader)
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.CastExpressionSyntax.<>c.<.cctor>b__24_0(ObjectReader r)
   at Roslyn.Utilities.ObjectReader.ReadObject()
   at Roslyn.Utilities.ObjectReader.ReadValueWorker()
   at Roslyn.Utilities.ObjectReader.ReadValue()
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.ParenthesizedExpressionSyntax..ctor(ObjectReader reader)
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.ParenthesizedExpressionSyntax.<>c.<.cctor>b__21_0(ObjectReader r)
   at Roslyn.Utilities.ObjectReader.ReadObject()
   at Roslyn.Utilities.ObjectReader.ReadValueWorker()
   at Roslyn.Utilities.ObjectReader.ReadValue()
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.MemberAccessExpressionSyntax..ctor(ObjectReader reader)
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.MemberAccessExpressionSyntax.<>c.<.cctor>b__21_0(ObjectReader r)
   at Roslyn.Utilities.ObjectReader.ReadObject()
   at Roslyn.Utilities.ObjectReader.ReadValueWorker()
   at Roslyn.Utilities.ObjectReader.ReadValue()
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.InvocationExpressionSyntax..ctor(ObjectReader reader)
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.InvocationExpressionSyntax.<>c.<.cctor>b__18_0(ObjectReader r)
   at Roslyn.Utilities.ObjectReader.ReadObject()
   at Roslyn.Utilities.ObjectReader.ReadValueWorker()
   at Roslyn.Utilities.ObjectReader.ReadValue()
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.ExpressionStatementSyntax..ctor(ObjectReader reader)
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.ExpressionStatementSyntax.<>c.<.cctor>b__21_0(ObjectReader r)
   at Roslyn.Utilities.ObjectReader.ReadObject()
   at Roslyn.Utilities.ObjectReader.ReadValueWorker()
   at Roslyn.Utilities.ObjectReader.ReadValue()
   at Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList.WithManyChildrenBase..ctor(ObjectReader reader)
   at Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList.WithLotsOfChildren.<>c.<.cctor>b__0_0(ObjectReader r)
   at Roslyn.Utilities.ObjectReader.ReadObject()
   at Roslyn.Utilities.ObjectReader.ReadValueWorker()
   at Roslyn.Utilities.ObjectReader.ReadValue()
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.BlockSyntax..ctor(ObjectReader reader)
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.BlockSyntax.<>c.<.cctor>b__24_0(ObjectReader r)
   at Roslyn.Utilities.ObjectReader.ReadObject()
   at Roslyn.Utilities.ObjectReader.ReadValueWorker()
   at Roslyn.Utilities.ObjectReader.ReadValue()
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.MethodDeclarationSyntax..ctor(ObjectReader reader)
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.MethodDeclarationSyntax.<>c.<.cctor>b__45_0(ObjectReader r)
   at Roslyn.Utilities.ObjectReader.ReadObject()
   at Roslyn.Utilities.ObjectReader.ReadValueWorker()
   at Roslyn.Utilities.ObjectReader.ReadValue()
   at Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList.WithManyChildrenBase..ctor(ObjectReader reader)
   at Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxList.WithLotsOfChildren.<>c.<.cctor>b__0_0(ObjectReader r)
   at Roslyn.Utilities.ObjectReader.ReadObject()
   at Roslyn.Utilities.ObjectReader.ReadValueWorker()
   at Roslyn.Utilities.ObjectReader.ReadValue()
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.ClassDeclarationSyntax..ctor(ObjectReader reader)
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.ClassDeclarationSyntax.<>c.<.cctor>b__45_0(ObjectReader r)
   at Roslyn.Utilities.ObjectReader.ReadObject()
   at Roslyn.Utilities.ObjectReader.ReadValueWorker()
   at Roslyn.Utilities.ObjectReader.ReadValue()
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.NamespaceDeclarationSyntax..ctor(ObjectReader reader)
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.NamespaceDeclarationSyntax.<>c.<.cctor>b__42_0(ObjectReader r)
   at Roslyn.Utilities.ObjectReader.ReadObject()
   at Roslyn.Utilities.ObjectReader.ReadValueWorker()
   at Roslyn.Utilities.ObjectReader.ReadValue()
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.CompilationUnitSyntax..ctor(ObjectReader reader)
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.CompilationUnitSyntax.<>c.<.cctor>b__27_0(ObjectReader r)
   at Roslyn.Utilities.ObjectReader.ReadObject()
   at Roslyn.Utilities.ObjectReader.ReadValueWorker()
   at Roslyn.Utilities.ObjectReader.ReadValue()
   at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxNode.DeserializeFrom(Stream stream, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTreeFactoryServiceFactory.CSharpSyntaxTreeFactoryService.DeserializeNodeFrom(Stream stream, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Host.AbstractSyntaxTreeFactoryService.RecoverableSyntaxRoot`1.RecoverRoot(Stream stream, CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Host.AbstractSyntaxTreeFactoryService.RecoverableSyntaxRoot`1.Recover(CancellationToken cancellationToken)
   at Roslyn.Utilities.AsyncLazy`1.GetValue(CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Host.WeaklyCachedRecoverableValueSource`1.GetValue(CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTreeFactoryServiceFactory.CSharpSyntaxTreeFactoryService.RecoverableSyntaxTree.GetRoot(CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTree.GetRootCore(CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTreeFactoryServiceFactory.CSharpSyntaxTreeFactoryService.PositionalSyntaxReference.GetSyntax(CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.CSharp.Symbols.SourceMemberContainerTypeSymbol.AddDeclaredNontypeMembers(DeclaredMembersAndInitializersBuilder builder, BindingDiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Symbols.SourceMemberContainerTypeSymbol.<BuildMembersAndInitializers>g__buildDeclaredMembersAndInitializers|152_1(BindingDiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Symbols.SourceMemberContainerTypeSymbol.<BuildMembersAndInitializers>g__getDeclaredMembersAndInitializers|152_0()
   at Microsoft.CodeAnalysis.CSharp.Symbols.SourceMemberContainerTypeSymbol.BuildMembersAndInitializers(BindingDiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Symbols.SourceMemberContainerTypeSymbol.GetMembersAndInitializers()
   at Microsoft.CodeAnalysis.CSharp.Symbols.SourceMemberContainerTypeSymbol.MakeAllMembers(BindingDiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Symbols.SourceMemberContainerTypeSymbol.GetMembersByNameSlow()
   at Microsoft.CodeAnalysis.CSharp.Symbols.SourceMemberContainerTypeSymbol.GetMembersByName()
   at Microsoft.CodeAnalysis.CSharp.Symbols.SourceMemberContainerTypeSymbol.GetMembers(String name)
   at Microsoft.CodeAnalysis.CSharp.Symbols.NamedTypeSymbol.GetConstructors(Boolean includeInstance, Boolean includeStatic)
   at Microsoft.CodeAnalysis.CSharp.Binder.GetAccessibleConstructorsForOverloadResolution(NamedTypeSymbol type, Boolean allowProtectedConstructorsOfBaseType, ImmutableArray`1& allInstanceConstructors, CompoundUseSiteInfo`1& useSiteInfo)
   at Microsoft.CodeAnalysis.CSharp.Binder.TryPerformConstructorOverloadResolution(NamedTypeSymbol typeContainingConstructors, AnalyzedArguments analyzedArguments, String errorName, Location errorLocation, Boolean suppressResultDiagnostics, BindingDiagnosticBag diagnostics, MemberResolutionResult`1& memberResolutionResult, ImmutableArray`1& candidateConstructors, Boolean allowProtectedConstructorsOfBaseType)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindClassCreationExpression(SyntaxNode node, String typeName, SyntaxNode typeNode, NamedTypeSymbol type, AnalyzedArguments analyzedArguments, BindingDiagnosticBag diagnostics, InitializerExpressionSyntax initializerSyntaxOpt, TypeSymbol initializerTypeOpt, Boolean wasTargetTyped)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindClassCreationExpression(ObjectCreationExpressionSyntax node, NamedTypeSymbol type, String typeName, BindingDiagnosticBag diagnostics, TypeSymbol initializerType)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindObjectCreationExpression(ObjectCreationExpressionSyntax node, BindingDiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindExpressionInternal(ExpressionSyntax node, BindingDiagnosticBag diagnostics, Boolean invoked, Boolean indexed)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindExpression(ExpressionSyntax node, BindingDiagnosticBag diagnostics, Boolean invoked, Boolean indexed)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindInferredVariableInitializer(BindingDiagnosticBag diagnostics, ExpressionSyntax initializer, BindValueKind valueKind, RefKind refKind, CSharpSyntaxNode errorSyntax)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindVariableDeclaration(SourceLocalSymbol localSymbol, LocalDeclarationKind kind, Boolean isVar, VariableDeclaratorSyntax declarator, TypeSyntax typeSyntax, TypeWithAnnotations declTypeOpt, AliasSymbol aliasOpt, BindingDiagnosticBag diagnostics, Boolean includeBoundType, CSharpSyntaxNode associatedSyntaxNode)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindDeclarationStatementParts(LocalDeclarationStatementSyntax node, BindingDiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindLocalDeclarationStatement(LocalDeclarationStatementSyntax node, BindingDiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindStatement(StatementSyntax node, BindingDiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindBlockParts(BlockSyntax node, BindingDiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindBlock(BlockSyntax node, BindingDiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindStatement(StatementSyntax node, BindingDiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindMethodBody(CSharpSyntaxNode declaration, BlockSyntax blockBody, ArrowExpressionClauseSyntax expressionBody, BindingDiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.Binder.BindMethodBody(CSharpSyntaxNode syntax, BindingDiagnosticBag diagnostics)
   at Microsoft.CodeAnalysis.CSharp.MethodCompiler.BindMethodBody(MethodSymbol method, TypeCompilationState compilationState, BindingDiagnosticBag diagnostics, VariableState nullableInitialState, ImportChain& importChain, Boolean& originalBodyNested, InitialState& forSemanticModel)
   at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileMethod(MethodSymbol methodSymbol, Int32 methodOrdinal, ProcessedFieldInitializers& processedInitializers, SynthesizedSubmissionFields previousSubmissionFields, TypeCompilationState compilationState)
   at Microsoft.CodeAnalysis.CSharp.MethodCompiler.CompileNamedType(NamedTypeSymbol containingType)
   at Microsoft.CodeAnalysis.CSharp.MethodCompiler.<>c__DisplayClass23_0.<CompileNamedTypeAsync>b__0()

https://github.com/dotnet/roslyn threw an exception: System.InvalidOperationException: Exception of type 'System.InvalidOperationException' was thrown.
   at System.Runtime.CompilerServices.ConditionalWeakTable`2.VerifyIntegrity()
   at System.Runtime.CompilerServices.ConditionalWeakTable`2.Add(TKey key, TValue value)
   at Microsoft.CodeAnalysis.GreenNode..ctor(ObjectReader reader)
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.MemberAccessExpressionSyntax..ctor(ObjectReader reader)
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.MemberAccessExpressionSyntax.<>c.<.cctor>b__21_0(ObjectReader r)
   at Roslyn.Utilities.ObjectReader.ReadObject()
   at Roslyn.Utilities.ObjectReader.ReadValueWorker()
   at Roslyn.Utilities.ObjectReader.ReadValue()
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.BinaryExpressionSyntax..ctor(ObjectReader reader)
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.BinaryExpressionSyntax.<>c.<.cctor>b__21_0(ObjectReader r)
   at Roslyn.Utilities.ObjectReader.ReadObject()
   at Roslyn.Utilities.ObjectReader.ReadValueWorker()
   at Roslyn.Utilities.ObjectReader.ReadValue()
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.ParenthesizedExpressionSyntax..ctor(ObjectReader reader)
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.ParenthesizedExpressionSyntax.<>c.<.cctor>b__21_0(ObjectReader r)
   at Roslyn.Utilities.ObjectReader.ReadObject()
   at Roslyn.Utilities.ObjectReader.ReadValueWorker()
   at Roslyn.Utilities.ObjectReader.ReadValue()
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.BinaryExpressionSyntax..ctor(ObjectReader reader)
   at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.BinaryExpressionSyntax.<>c.<.cctor>b__21_0(ObjectReader r)
   at Roslyn.Utilities.ObjectReader.ReadObject()
   at Roslyn.Utilities.ObjectReader.ReadValueWorker()
   at Roslyn.Utilities.ObjectReader.ReadValue()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions