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.
driis source
share