Memory usage in C# Memory usage in C# multithreading multithreading

Memory usage in C#


If you want the memory of the entire running process and not on a per thread basis, how about:

// get the current processProcess currentProcess = System.Diagnostics.Process.GetCurrentProcess();// get the physical mem usagelong totalBytesOfMemoryUsed = currentProcess.WorkingSet64;

There's a whole host of other process memory properties besides WorkingSet64 check out the "memory related" ones at the following link for the one that best suit

http://msdn.microsoft.com/en-us/library/system.diagnostics.process_properties.aspx


While I agree with the comments you've already received on your question, the use of System.Environment.WorkingSet might perhaps be an actual answer to it if you really decide to take this course of action?


I'm with Will and Steve, don't do this unless you REALLY have to do it . . . that said . . .

if you really need to do it you can use the .Net Hosting APIs they're there so apps like SQL Server can host the .net framework within the application.

It gives you control over memory management etc, I've read the article but never used the API's, they're on my to-do list for some night when I'm bored and none of my other "fun" projects feel like fun that week :)

Hope this helps.