How to get the amount of memory used by an application
You can try GC.GetTotalMemory
:
It Retrieves the number of bytes currently thought to be allocated. A parameter indicates whether this method can wait a short interval > before returning, to allow the system to collect garbage and finalize > objects.
or
using System.Diagnostics;
Process currentProc = Process.GetCurrentProcess();
Once you have a reference to the current process, you can determine its memory usage by reading the PrivateMemorySize64 property.
long memoryUsed = currentProc.PrivateMemorySize64;
You can use the following function (The true parameter tells the GC to perform a collection first):
long memory = GC.GetTotalMemory(true);