dotnet/runtime

On macOS `Process.PrivateMemorySize64` returns `0`

Open

#105,665 建立於 2024年7月29日

在 GitHub 查看
 (2 留言) (0 反應) (0 負責人)C# (5,445 fork)batch import
area-System.Diagnostics.Processhelp wantedneeds-further-triageos-mac-os-x

倉庫指標

Star
 (17,886 star)
PR 合併指標
 (平均合併 12天 11小時) (30 天內合併 661 個 PR)

描述

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

貢獻者指南