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

Weird PublishAot memory differences without actually publishing #113219

Open
ThomasFOG opened this issue Mar 6, 2025 · 2 comments
Open

Weird PublishAot memory differences without actually publishing #113219

ThomasFOG opened this issue Mar 6, 2025 · 2 comments
Labels
area-Diagnostics-coreclr untriaged New issue has not been triaged by the area owner

Comments

@ThomasFOG
Copy link

ThomasFOG commented Mar 6, 2025

Description

Hello,

This is really puzzling in a way that it makes me doubt of myself.

While debugging from Visual Studio in DEBUG configuration, apps don't have the same memory behavior depending on whether PublishAot is set (which shouldn't even trigger outside dotnet publish, right?) and on whether the debugger is attached.

While debugging and PublishAot isn't set, memory will keep building up like if there were memory allocations going on.

While debugging and PublisAot is set, memory doesn't build up and remains stable if we don't allocate anything.

When the same exe is run without the debugger, memory is stable no matter what. This only happens when the debugger is attached and PublishAot isn't set.

Don't know if this has something to do with some runtime analyzers?

Happens in both VS 17.13.2 and 17.12.

VS components installed:

  • Visual C++ 2022 00482-90000-00000-AA134
  • Microsoft Visual C++ 2022
  • ASP.NET and Web Tools 17.13.124.35287
  • ASP.NET and Web Tools
  • Azure App Service Tools v3.0.0 17.13.124.35287
  • Azure App Service Tools v3.0.0
  • C# Tools 4.13.0-3.25112.7+afe5bc4a827030229ab79ec596b3cb91d4e87872
  • Microsoft JVM Debugger 1.0
  • Mono Debugging for Visual Studio 17.13.14 (1c94ab9)
  • NuGet Package Manager 6.13.2
  • Razor (ASP.NET Core) 17.13.3.2511303+2405f884fd9c848997c6be0607b18b55544f526a
  • TypeScript Tools 17.0.31211.2001
  • Visual Basic Tools 4.13.0-3.25112.7+afe5bc4a827030229ab79ec596b3cb91d4e87872
  • Visual F# Tools 17.13.0-beta.25056.5+63a09289745da5c256e7baf5f4194a750b1ec878
  • Visual Studio IntelliCode 2.2
  • VisualStudio.DeviceLog 1.0
  • VisualStudio.Mac 1.0
  • VSPackage Extension 1.0
  • Xamarin 17.13.0.171 (d17.13@5b137a5)
  • Xamarin Designer 17.13.3.4 (remotes/origin/main@59e9def289)
  • Xamarin.Android SDK 13.2.2.0 (d17-5/45b0e14)

Reproduction Steps

Debug from Visual Studio the most simple app and add/remove PublishAot.

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net9.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
  </PropertyGroup>

</Project>
Console.WriteLine("Hello, World!");

long test = System.GC.GetTotalMemory(false);

while (true)
{
    long test2 = System.GC.GetTotalMemory(false);

    if (test2 != test)
        System.Diagnostics.Debug.WriteLine(test2 - test);
}

Expected behavior

Memory behavior should stay the same?

Actual behavior

Memory behavior should stay the same?

Regression?

No response

Known Workarounds

No response

Configuration

Tested on .NET 9.0.103, 9.0.200, and 8.0.406.

Other information

No response

@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Mar 6, 2025
Copy link
Contributor

Tagging subscribers to this area: @tommcdon
See info in area-owners.md if you want to be subscribed.

@vitek-karas
Copy link
Member

PublishAot is set (which shouldn't even trigger outside dotnet publish, right?)

PublishAot=true modifies some feature switches so the runtime behavior is different. The goal is that the runtime behavior should be the same in debug and release (so without AOT and with AOT). It's possible that one of these affects memory behavior, but I don't know if that's the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Diagnostics-coreclr untriaged New issue has not been triaged by the area owner
Projects
None yet
Development

No branches or pull requests

2 participants