dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.47k stars 4.76k forks source link

[iOS] System.Diagnostics.Process is not supported #86251

Open Soap-141 opened 1 year ago

Soap-141 commented 1 year ago

Description

For diagnostics and debugging purposes my team and I would like to have Process.GetCurrentProcess().PrivateMemorySize64 working on iOS.

See https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.process.getcurrentprocess?view=net-6.0 and https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.process.privatememorysize64?view=net-6.0 for more details.

Reproduction Steps

Use this code snippet on Xamarin or MAUI iOS.

var currentProcess = Process.GetCurrentProcess();
var privateMemory = currentProcess.PrivateMemorySize64;

Notice it's throwing exception.

Expected behavior

Should not throw any exception and work like it's supposed to.

Actual behavior

Throws an exception.

Regression?

No response

Known Workarounds

No response

Configuration

Other information

No response

ghost commented 1 year ago

Tagging subscribers to this area: @dotnet/area-system-diagnostics-process See info in area-owners.md if you want to be subscribed.

Issue Details
### Description For diagnostics and debugging purposed my team and I would like to have `Process.GetCurrentProcess().PrivateMemorySize64` working on iOS. See https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.process.getcurrentprocess?view=net-6.0 and https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.process.privatememorysize64?view=net-6.0 for more details. See for more details. ### Reproduction Steps Use this code snippet on Xamarin or MAUI iOS. ``` cs var currentProcess = Process.GetCurrentProcess(); var privateMemory = currentProcess .PrivateMemorySize64; ``` Notice it's throwing exception. ### Expected behavior Should not throw any exception and work like it's supposed to. ### Actual behavior Throws an exception. ### Regression? _No response_ ### Known Workarounds _No response_ ### Configuration - .NET 6/7 ### Other information _No response_
Author: Soap-141
Assignees: -
Labels: `area-System.Diagnostics.Process`
Milestone: -
hoyosjs commented 1 year ago

@akoeplinger is there a native way that iOS supports working set? I thought process was largely unsupported out of the lack of fork abilities, but is introspection also not supported?

akoeplinger commented 1 year ago

We're using proc_pidinfo to get these details on macOS and unfortunately that API is not allowed by Apple on the iOS App Store so we had to remove it: https://github.com/dotnet/runtime/issues/61265

That said, there's nothing stopping you from using this API on your own e.g. behind a DEBUG flag that you never compile for a build that ends up on the App Store.

I'll take a quick look to see whether there is some allowed API that gives just the memory details though.

ghost commented 1 year ago

Tagging subscribers to 'os-ios': @steveisok, @akoeplinger See info in area-owners.md if you want to be subscribed.

Issue Details
### Description For diagnostics and debugging purposes my team and I would like to have `Process.GetCurrentProcess().PrivateMemorySize64` working on iOS. See https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.process.getcurrentprocess?view=net-6.0 and https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.process.privatememorysize64?view=net-6.0 for more details. See for more details. ### Reproduction Steps Use this code snippet on Xamarin or MAUI iOS. ``` cs var currentProcess = Process.GetCurrentProcess(); var privateMemory = currentProcess .PrivateMemorySize64; ``` Notice it's throwing exception. ### Expected behavior Should not throw any exception and work like it's supposed to. ### Actual behavior Throws an exception. ### Regression? _No response_ ### Known Workarounds _No response_ ### Configuration - .NET 6/7 ### Other information _No response_
Author: Soap-141
Assignees: -
Labels: `area-System.Diagnostics.Process`, `os-ios`
Milestone: Future
Soap-141 commented 1 year ago

@akoeplinger Any updates?

Soap-141 commented 1 year ago

Still no updates?