How to get shared memory programmatically using a .NET application (ASP)?

How can I programmatically check how much memory is allocated by my program?

I need this for an ASP.NET application, but I suspect that the solution is common to all types of .NET applications. Ideally, the operation to get the allocated memory should be fast, since I will need to request it often.

EDIT: Thanks for your answers. I will use GC.GetTotalMemory for this task, since I need to use it for an ASP.NET application. After some experimentation, I determined that it was fast and accurate enough for my needs. The proposal to use the Process' PrivateMemorySize64 property will also work as a whole; but as indicated in the answers, for an ASP.NET application there will often be several AppDomain applications in the same process. I need shared memory for each application.

+3
source share
3 answers

There is a GC.GetTotalMemory method , but this will give you an approximate value. is that enough?

GC.GetTotalMemory(false), ...

+6

, asp.net . , PrivateMemorySize64. GC.GetTotalMemory afaik.

+2

PrivateMemorySize64 ( Virtual, ) Process. , Refresh.

+1

All Articles