Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

High memory usage in Blazor app, when built with wasm-tools workload installed #73949

Closed
1 task done
ysmoradi opened this issue Aug 14, 2022 · 13 comments
Closed
1 task done
Assignees
Labels
arch-wasm WebAssembly architecture area-VM-meta-mono needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration
Milestone

Comments

@ysmoradi
Copy link
Contributor

ysmoradi commented Aug 14, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

If I publish the default project template of the blazor web assembly app which has counter/weather/index pages using visual studio 17.3 stable and .net SDK 7 preview 7, the memory usage would be about 50 MB
But afterI install the wasm-tools workload, the memory usage increases significantly (about 540MB which is 10X more memory usage and the app becomes slower in the initialization phase by about 1 second)

Expected Behavior

I'd expect the same behavior about memory usage, with or without wasm-tools

Steps To Reproduce

Install VS 17.3 stable
Install .NET 7 preview 7
Enable using preview versions of .NET SDK in VS
Create a new blazor web assembly project
Publish that and run that and then use chrome dev tools to take a heap snapshot
The memory usage would be something like this:
image
Install wasm-tools using dotnet workload install wasm-tools
Close / Open Visual Studio
Publish that app again and run that and then use chrome dev tools to take a heap snapshot
The memory usage would be something like this:
image

Exceptions (if any)

No response

.NET Version

7.0.100-preview.7.22377.5

Anything else?

Note that I've to install wasm-tools
Without that, I'm unable to build blazor web assembly projects using dotnet build command in CI/CD pipeline
It also reduces download size about 0.5MB when I use <InvariantGlobalization>true</InvariantGlobalization>

@MackinnonBuck MackinnonBuck transferred this issue from dotnet/aspnetcore Aug 15, 2022
@ghost ghost added the untriaged New issue has not been triaged by the area owner label Aug 15, 2022
@radical radical changed the title High memory usage when I run dotnet workload install wasm-tools High memory usage in Blazor app, when built with wasm-tools workload installed Aug 15, 2022
@radical radical added arch-wasm WebAssembly architecture area-blazor labels Aug 15, 2022
@ghost
Copy link

ghost commented Aug 15, 2022

Tagging subscribers to 'arch-wasm': @lewing
See info in area-owners.md if you want to be subscribed.

Issue Details

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

If I publish the default project template of the blazor web assembly app which has counter/weather/index pages using visual studio 17.3 stable and .net SDK 7 preview 7, the memory usage would be about 50 MB
But afterI install the wasm-tools workload, the memory usage increases significantly (about 540MB which is 10X more memory usage and the app becomes slower in the initialization phase by about 1 second)

Expected Behavior

I'd expect the same behavior about memory usage, with or without wasm-tools

Steps To Reproduce

Install VS 17.3 stable
Install .NET 7 preview 7
Enable using preview versions of .NET SDK in VS
Create a new blazor web assembly project
Publish that and run that and then use chrome dev tools to take a heap snapshot
The memory usage would be something like this:
image
Install wasm-tools using dotnet workload install wasm-tools
Close / Open Visual Studio
Publish that app again and run that and then use chrome dev tools to take a heap snapshot
The memory usage would be something like this:
image

Exceptions (if any)

No response

.NET Version

7.0.100-preview.7.22377.5

Anything else?

Note that I've to install wasm-tools
Without that, I'm unable to build blazor web assembly projects using dotnet build command in CI/CD pipeline
It also reduces download size about 0.5MB when I use <InvariantGlobalization>true</InvariantGlobalization>

Author: ysmoradi
Assignees: -
Labels:

arch-wasm, untriaged, area-blazor

Milestone: -

@radical
Copy link
Member

radical commented Aug 15, 2022

@ysmoradi

  1. How are you building this? Is this a build, or publish?
  2. Can you share the binlog? (You can use https://marketplace.visualstudio.com/items?itemName=VisualStudioProductTeam.ProjectSystemTools2022 to get the binlog in VS)
  3. Is this with the blazor template project?

Note that I've to install wasm-tools
Without that, I'm unable to build blazor web assembly projects using dotnet build command in CI/CD pipeline

What errors did you get without wasm-tools?

cc @javiercn @radekdoulik

@radical radical added the needs-author-action An issue or pull request that requires more info or actions from the author. label Aug 15, 2022
@ghost
Copy link

ghost commented Aug 15, 2022

This issue has been marked needs-author-action and may be missing some important information.

@ysmoradi
Copy link
Contributor Author

@ysmoradi

  1. How are you building this? Is this a build, or publish?
  2. Can you share the binlog? (You can use https://marketplace.visualstudio.com/items?itemName=VisualStudioProductTeam.ProjectSystemTools2022 to get the binlog in VS)
  3. Is this with the blazor template project?

Note that I've to install wasm-tools
Without that, I'm unable to build blazor web assembly projects using dotnet build command in CI/CD pipeline

What errors did you get without wasm-tools?

cc @javiercn @radekdoulik

1- Simply right click on the newly created blazor web assembly + aspnetcore backend project and perform publish

2- Will submit in separated responses

3- No particular error. I'd expect a size reduction in dotnet.wasm when I publish with <InvariantGlobalization>true</InvariantGlobalization> but It only happens when I install wasm-tools.

@ghost ghost added needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration and removed needs-author-action An issue or pull request that requires more info or actions from the author. labels Aug 16, 2022
@ysmoradi
Copy link
Contributor Author

Microsoft Visual Studio Community 2022
Version 17.3.0
VisualStudio.17.Release/17.3.0+32804.467
Microsoft .NET Framework
Version 4.8.09037

Installed Version: Community

Visual C++ 2022 00482-10000-00261-AA784
Microsoft Visual C++ 2022

ASP.NET and Web Tools 17.3.375.53775
ASP.NET and Web Tools

Azure App Service Tools v3.0.0 17.3.375.53775
Azure App Service Tools v3.0.0

Azure Functions and Web Jobs Tools 17.3.375.53775
Azure Functions and Web Jobs Tools

C# Tools 4.3.0-3.22401.3+41ae77386c335929113f61d6f51f2663d2780443
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.

Extensibility Message Bus 1.2.6 (master@34d6af2)
Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.

Microsoft Azure Tools for Visual Studio 2.9
Support for Azure Cloud Services projects

Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Mono Debugging for Visual Studio 17.3.20 (3f4cb00)
Support for debugging Mono processes with Visual Studio.

NuGet Package Manager 6.3.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

Project System Tools 1.0
Tools for working with C#, VisualBasic, and F# projects.

Razor (ASP.NET Core) 17.0.0.2232702+e1d654e792aa2fe6646a6935bcca80ff0aff4387
Provides languages services for ASP.NET Core Razor.

SQL Server Data Tools 17.0.62207.04100
Microsoft SQL Server Data Tools

TypeScript Tools 17.0.10701.2001
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools 4.3.0-3.22401.3+41ae77386c335929113f61d6f51f2663d2780443
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.1.0-beta.22363.4+1b94f89d4d1f41f20f9be73c76f4b229d4e49078
Microsoft Visual F# Tools

Visual Studio IntelliCode 2.2
AI-assisted development for Visual Studio.

VisualStudio.DeviceLog 1.0
Information about my package

VisualStudio.Mac 1.0
Mac Extension for Visual Studio

VSPackage Extension 1.0
VSPackage Visual Studio Extension Detailed Info

Web Compiler 1.14.8
Compiler for LESS, Sass and CoffeeScript files

Xamarin 17.3.0.295 (d17-3@321c85a)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer 17.3.0.208 (remotes/origin/d17-3@e4f67afef)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin Templates 17.2.28 (9b3d244)
Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

Xamarin.Android SDK 13.0.0.0 (d17-3/030cd63)
Xamarin.Android Reference Assemblies and MSBuild support.
Mono: dffa5ab
Java.Interop: xamarin/java.interop/d17-3@7716ae53
SQLite: xamarin/sqlite@df4deab
Xamarin.Android Tools: xamarin/xamarin-android-tools/main@14076a6

Xamarin.iOS and Xamarin.Mac SDK 15.12.0.2 (87f98a75e)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

@ysmoradi
Copy link
Contributor Author

.NET SDK:
 Version:   7.0.100-preview.7.22377.5
 Commit:    ba310d9309

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19044
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\7.0.100-preview.7.22377.5\

Host:
  Version:      7.0.0-preview.7.22375.6
  Architecture: x64
  Commit:       eecb028078

.NET SDKs installed:
  6.0.400 [C:\Program Files\dotnet\sdk]
  7.0.100-preview.7.22377.5 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 5.0.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.0-preview.7.22376.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 5.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.0-preview.7.22375.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 5.0.12 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 7.0.0-preview.7.22377.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  
  wasm-tools                  7.0.0-preview.7.22375.6/7.0.100      SDK 7.0.100-preview.7

@lewing lewing added this to the 8.0.0 milestone Aug 17, 2022
@lewing lewing removed the untriaged New issue has not been triaged by the area owner label Aug 17, 2022
@lewing
Copy link
Member

lewing commented Aug 17, 2022

cc @BrzVlad

@lewing
Copy link
Member

lewing commented Aug 17, 2022

Installing the workload enables relinking and another wasm-opt pass, I wonder if it is interacting with the gc in some way

@msynk
Copy link

msynk commented Aug 21, 2022

+1

@Swiftless
Copy link

Swiftless commented Nov 25, 2022

Also hitting this issue, extremely long build times when using the Publish button to an Azure Virtual Machine, longer than 10 minutes - a local build on the Release configuration is finished in less than a minute. Memory usage for Visual Studio 2022 and .NET Host fluxuate wildly (up and down) with each up being higher than the last. As I type this it's up to 8.5GB Memory usage for Visual Studio and .NET Host is about 5GB and they keep rising. Now it's at 9.3GB and 6.5GB. Now 11.4GB and 8GB. .

Using Visual Studio 2022 Preview (17.5.0 Preview 1.0).

Note: I also get the same long build time and high memory issue when I Publish to a folder, it's not the publish step that's the issue.

Update: I switched back to Visual Studio 2022 17.4 and still encountered the issue. BUT I manage to "fix" it by turning off trimming in both the Client and Server projects. 18 minutes down to 3 minutes and most of that 3 minutes was the actual file upload.

It was getting stuck on illink in the build output.

Unfortunately without playing further I'm currently left without trimming.

@pavelsavara
Copy link
Member

Installing the workload enables relinking and another wasm-opt pass, I wonder if it is interacting with the gc in some way

I think it's duplicate of #61925

@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Jan 19, 2023
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Feb 8, 2023
@pavelsavara
Copy link
Member

Fixed by #80849

@ghost ghost locked as resolved and limited conversation to collaborators Mar 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-wasm WebAssembly architecture area-VM-meta-mono needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration
Projects
None yet
Development

No branches or pull requests

10 participants