ASP.NET Core Controller API has a higth memory consomation when started in debug from recent Visual Studio version

Vernou 86 Reputation points
2024-11-04T16:46:56.72+00:00

Hi,

We have developed a ASP.NET Core Controller API that work.

From we updated Visual Studio from 17.10.4 to 17.11.5, when the API is started in debug from Visual Studio, the memory consumption is rising rapidly :

User's image

The API work fine when started by executing the exe from cmd and next attach to Visual Studio debugger. So sound the problem come from Visual Studio.

When I pause and check the stack trace :

...
Microsoft.AspNetCore.Mvc.ApiExplorer.dll!Microsoft.AspNetCore.Mvc.ApiExplorer.DefaultApiDescriptionProvider.PseudoModelBindingVisitor.Visit(Microsoft.AspNetCore.Mvc.ApiExplorer.DefaultApiDescriptionProvider.ApiParameterDescriptionContext bindingContext, Microsoft.AspNetCore.Mvc.ModelBinding.BindingSource ambientSource, string containerName)    Unknown
Microsoft.AspNetCore.Mvc.ApiExplorer.dll!Microsoft.AspNetCore.Mvc.ApiExplorer.DefaultApiDescriptionProvider.GetParameters(Microsoft.AspNetCore.Mvc.ApiExplorer.ApiParameterContext context)               Unknown
Microsoft.AspNetCore.Mvc.ApiExplorer.dll!Microsoft.AspNetCore.Mvc.ApiExplorer.DefaultApiDescriptionProvider.CreateApiDescription(Microsoft.AspNetCore.Mvc.Controllers.ControllerActionDescriptor action, string httpMethod, string groupName)    Unknown
Microsoft.AspNetCore.Mvc.ApiExplorer.dll!Microsoft.AspNetCore.Mvc.ApiExplorer.DefaultApiDescriptionProvider.OnProvidersExecuting(Microsoft.AspNetCore.Mvc.ApiExplorer.ApiDescriptionProviderContext context)               Unknown
Microsoft.AspNetCore.Mvc.ApiExplorer.dll!Microsoft.AspNetCore.Mvc.ApiExplorer.ApiDescriptionGroupCollectionProvider.GetCollection(Microsoft.AspNetCore.Mvc.Infrastructure.ActionDescriptorCollection actionDescriptors)           Unknown
Microsoft.AspNetCore.Mvc.ApiExplorer.dll!Microsoft.AspNetCore.Mvc.ApiExplorer.ApiDescriptionGroupCollectionProvider.ApiDescriptionGroups.get()               Unknown
Microsoft.WebTools.ApiEndpointDiscovery.dll!Microsoft.WebTools.ApiEndpointDiscovery.ApplicationEndpointWriter.WriteEndpointsAsync(string fileName, System.IServiceProvider serviceProvider, System.Threading.CancellationToken cancelToken)      Unknown
Microsoft.WebTools.ApiEndpointDiscovery.dll!Microsoft.WebTools.ApiEndpointDiscovery.HostingStartup.Configure.AnonymousMethod__1()               Unknown
System.Private.CoreLib.dll!System.Threading.CancellationTokenSource.Invoke(System.Delegate d, object state, System.Threading.CancellationTokenSource source)          Unknown
System.Private.CoreLib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state)        Unknown
System.Private.CoreLib.dll!System.Threading.CancellationTokenSource.ExecuteCallbackHandlers(bool throwOnFirstException)  Unknown
Microsoft.Extensions.Hosting.dll!Microsoft.Extensions.Hosting.Internal.ApplicationLifetime.NotifyStarted()               Unknown
Microsoft.Extensions.Hosting.dll!Microsoft.Extensions.Hosting.Internal.Host.StartAsync(System.Threading.CancellationToken cancellationToken)           Unknown
Microsoft.Extensions.Hosting.Abstractions.dll!Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(Microsoft.Extensions.Hosting.IHost host, System.Threading.CancellationToken token)             Unknown
Microsoft.Extensions.Hosting.Abstractions.dll!Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(Microsoft.Extensions.Hosting.IHost host)      Unknown
MyPorject.Api.dll!Program.<Main>$(string[] args)

I think Microsoft.WebTools.ApiEndpointDiscovery.dll is responsible. It try to explore endpoint, as the endpoint has recursive parameter, it do infinite loop.


We have computers where Visual Studio isn't updated and the API work in debug. See Visual Studio Info

Microsoft Visual Studio Professional 2022
Version 17.10.4
VisualStudio.17.Release/17.10.4+35027.167
Microsoft .NET Framework
Version 4.8.03761
 
Installed Version: Professional
 
ASP.NET and Web Tools   17.10.344.38934
ASP.NET and Web Tools
 
Azure App Service Tools v3.0.0   17.10.344.38934
Azure App Service Tools v3.0.0
 
Azure Functions and Web Jobs Tools   17.10.344.38934
Azure Functions and Web Jobs Tools
 
C# Tools   4.10.0-3.24324.8+04fb39164c99c519832109f21b22630bc9246fce
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
 
Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.
 
Fine Code Coverage   FineCodeCoverage2022.ad53fb28-7a11-4465-a27a-3550499ea4a1
Visualize unit test code coverage easily for free in Visual Studio Community Edition (and other editions too)
 
GitHub Copilot   0.2.889.30432
GitHub Copilot is an AI pair programmer that helps you write code faster and with less work.
 
Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines
 
NuGet Package Manager   6.10.1
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/
 
Office Developer Tools for Visual Studio   17.10.34627.00
Microsoft Office Developer Tools for Visual Studio
 
Razor (ASP.NET Core)   17.10.3.2427201+4f57d1de251e654812adde201c0265a8ca7ca31d
Provides languages services for ASP.NET Core Razor.
 
SQL Server Data Tools   17.10.178.1
Microsoft SQL Server Data Tools
 
TypeScript Tools   17.0.30327.2001
TypeScript Tools for Microsoft Visual Studio
 
Visual Basic Tools   4.10.0-3.24324.8+04fb39164c99c519832109f21b22630bc9246fce
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
 
Visual F# Tools   17.10.0-beta.24228.1+dd749058c91585e9b5dae62b0f8df892429ee28f
Microsoft Visual F# Tools
 
Visual Studio IntelliCode   2.2
AI-assisted development for Visual Studio.
 
Workflow Manager Tools 1.0   1.0
This package contains the necessary Visual Studio integration components for Workflow Manager.

See Visual Studio Info from a computer where the API don't work :

Microsoft Visual Studio Professional 2022
Version 17.11.5
VisualStudio.17.Release/17.11.5+35327.3
Microsoft .NET Framework
Version 4.8.03761
 
Installed Version: Professional
 
Visual C++ 2022   00483-10050-32035-AA538
Microsoft Visual C++ 2022
 
ADL Tools Service Provider   1.0
This package contains services used by Data Lake tools
 
ASA Service Provider   1.0
 
ASP.NET and Web Tools   17.11.231.19466
ASP.NET and Web Tools
 
Azure App Service Tools v3.0.0   17.11.231.19466
Azure App Service Tools v3.0.0
 
Azure Data Lake Tools for Visual Studio   2.6.5000.0
Microsoft Azure Data Lake Tools for Visual Studio
 
Azure Functions and Web Jobs Tools   17.11.231.19466
Azure Functions and Web Jobs Tools
 
Azure Stream Analytics Tools for Visual Studio   2.6.5000.0
Microsoft Azure Stream Analytics Tools for Visual Studio
 
C# Tools   4.11.0-3.24460.3+5649376e0e5f5db3743a94a62b073f2cce4be5d9
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
 
Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.
 
Fine Code Coverage   FineCodeCoverage2022.ad53fb28-7a11-4465-a27a-3550499ea4a1
Visualize unit test code coverage easily for free in Visual Studio Community Edition (and other editions too)
 
GitHub Copilot   0.2.1657.32929
GitHub Copilot is an AI pair programmer that helps you write code faster and with less work.
 
Microsoft Azure Hive Query Language Service   2.6.5000.0
Language service for Hive query
 
Microsoft Azure Stream Analytics Language Service   2.6.5000.0
Language service for Azure Stream Analytics
 
Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines
 
NuGet Package Manager   6.11.1
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/
 
Open in NSwagStudio   Unchase OpenAPI (Swagger) Connected Service
Adds a menu command that lets you open nswag file in NSwagStudio.
 
Razor (ASP.NET Core)   17.11.3.2442001+68650a7d94261bc56a1f4bc522c2ee35314b1abb
Provides languages services for ASP.NET Core Razor.
 
SQL Server Data Tools   17.11.47.0
Microsoft SQL Server Data Tools
 
ToolWindowHostedEditor   1.0
Hosting json editor into a tool window
 
TypeScript Tools   17.0.30715.2002
TypeScript Tools for Microsoft Visual Studio
 
Visual Basic Tools   4.11.0-3.24460.3+5649376e0e5f5db3743a94a62b073f2cce4be5d9
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
 
Visual F# Tools   17.11.0-beta.24421.7+af2f522de602281d4ef5a7b71507c428e814c5c1
Microsoft Visual F# Tools
 
Visual Studio IntelliCode   2.2
AI-assisted development for Visual Studio.

How can resolve that (without modify the API code)?

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,653 questions
Visual Studio Debugging
Visual Studio Debugging
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Debugging: The act or process of detecting, locating, and correcting logical or syntactical errors in a program or malfunctions in hardware. In hardware contexts, the term troubleshoot is the term more frequently used, especially if the problem is major.
1,006 questions
0 comments No comments
{count} votes

Accepted answer
  1. Anna Xiu-MSFT 30,011 Reputation points Microsoft Vendor
    2024-11-05T06:53:06.8233333+00:00

    Hi @Vernou, 

    Welcome to Microsoft Q&A! 

    It seems be a known issue with Endpoint Explorer. You could see the following similar issue and refer to other users’ suggestions.

    ASP.NET Core Web API controller memory leak - Developer Community

    I recommend you directly report it to product team by selecting Help > Send Feedback > Report a Problem. Thanks for your understanding. 

    Sincerely,

    Anna


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".  Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.