You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
On macOS Process.PrivateMemorySize64 returns 0 #105665
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
Per macOS libproc header file proc_info.h (screenshot attached), the response from that API incldues only virtual memory size and resident memory size. Hence the field PrivateBytes in ProcessInfo is not assigned, remains default value.
Postscript
This issue is known from very first commit of ProcessManager.OSX, It is a comment there mentioning fields didn't being assigned as not available in macOS.
Activity
dotnet-policy-service commentedon Jul 29, 2024
Tagging subscribers to this area: @dotnet/area-system-diagnostics-process
See info in area-owners.md if you want to be subscribed.
ShawnWu33 commentedon Oct 6, 2024
Hi, did a bit investigation on this. Apology first if the terminologies are not accurate enough as I am new to this community.
TL;DR
The private memory size of a process is not exposed in macOS (OSX) SDK, hence the value remains default int value as 0;
Investigation details
The
Process.PrivateMemorySize64having a getter function which will first ensure process information being retrieved.runtime/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.cs
Lines 494 to 501 in 112ef3d
When process information did not existed, it trigger ProcessManager to retrieve the process information.
runtime/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.cs
Lines 978 to 984 in 112ef3d
The process manager invoke
Interop.libproc.GetProcessInfoById(pid)to get process information.runtime/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.OSX.cs
Line 44 in 112ef3d
proc_pidinforuntime/src/libraries/Common/src/Interop/OSX/Interop.libproc.GetProcessInfoById.cs
Line 116 in 112ef3d
Per macOS libproc header file proc_info.h (screenshot attached), the response from that API incldues only virtual memory size and resident memory size. Hence the field
PrivateBytesin ProcessInfo is not assigned, remains default value.Postscript
This issue is known from very first commit of ProcessManager.OSX, It is a comment there mentioning fields didn't being assigned as not available in macOS.
runtime/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.OSX.cs
Lines 69 to 75 in 112ef3d
So I don't see a proper fix available at curren time point.
nwoolls commentedon Jul 23, 2026
@adamsitnik I've staged a PR that addresses this shortcoming on macOS.
Populate PrivateMemorySize64 on macOS (#131244)