Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get memory available or used in C# .net core / .net standard

Is there a way to know the current used memory in the current process?

I checked many questions: How to get the amount of memory used by an application

How to get memory available or used in C#

They are not available in .Net Standard 1.6.

like image 469
Sawan Avatar asked Jul 23 '17 18:07

Sawan


1 Answers

Here you can check how it is done in HealthChecks project. You can use Process class from System.Diagnostics namespace.

* EDIT *

System.Diagnostics.Process Nuget package might need to be added.

Only xxxx64 memory properties are supported in .NET Standard (for example PrivateMemorySize64 and not PrivateMemorySize).

like image 183
Krzysztof Branicki Avatar answered Oct 27 '22 17:10

Krzysztof Branicki