dotnet/runtime

On macOS `Process.PrivateMemorySize64` returns `0`

Open

#105 665 ouverte le 29 juil. 2024

Voir sur GitHub
 (2 commentaires) (0 réactions) (0 assignés)C# (5 445 forks)batch import
area-System.Diagnostics.Processhelp wantedneeds-further-triageos-mac-os-x

Métriques du dépôt

Stars
 (17 886 stars)
Métriques de merge PR
 (Merge moyen 12j 11h) (661 PRs mergées en 30 j)

Description

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

Guide contributeur