dotnet/runtime

On macOS `Process.PrivateMemorySize64` returns `0`

Open

#105.665 aperta il 29 lug 2024

Vedi su GitHub
 (2 commenti) (0 reazioni) (0 assegnatari)C# (5445 fork)batch import
area-System.Diagnostics.Processhelp wantedneeds-further-triageos-mac-os-x

Metriche repository

Star
 (17.886 star)
Metriche merge PR
 (Merge medio 12g 11h) (661 PR mergiate in 30 g)

Descrizione

Description

Accessing Process.PrivateMemorySize64 on macOS returns 0. This was initially reported, and fixed, for Linux here. Follow-up comments mention macOS but the issue was closed.

The implementation of AssertNonZeroAllZeroDarwin seems to indicate this is acknowledged, if not by-design. But the XML comments for Process.PrivateMemorySize64 doesn't mention any such limitation.

Not sure if this is a bug or feature request, but I'd love to see this implemented for macOS. We're trying to troubleshoot some memory usage but coming up short in our dev environments because of this.

Reproduction Steps

mkdir app-macos-PrivateMemorySize64
cd app-macos-PrivateMemorySize64
dotnet new console
using System.Diagnostics;

var process = Process.GetCurrentProcess();
Console.WriteLine(process.PrivateMemorySize64);
dotnet run

Expected behavior

Outputs "the amount of private memory, in bytes, allocated for the associated process".

Actual behavior

Outputs 0.

Regression?

No

Known Workarounds

None

Configuration

dotnet --version
8.0.303
sw_vers
ProductName:		macOS
ProductVersion:		14.5
BuildVersion:		23F79
uname -a
Darwin nathanialsmbpm2.lan 23.5.0 Darwin Kernel Version 23.5.0: Wed May  1 20:14:38 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6020 arm64

Other information

No response

Guida contributor