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

Sawan picture Sawan · Jul 23, 2017 · Viewed 9k times · Source

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.

Answer

Krzysztof Branicki picture Krzysztof Branicki · Jul 23, 2017

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).