Accessing memory usage for current Application (or AppDomain)?
-
Is it possible to access the current memory usage values for the running application, from within the applications own code? I have had a hard time finding documentation on this. At first I tried to use the performance monitor classes, but I can't see a way to load up a performance monitor for the current process. Is this possible in .NET? I appreciate any replies.
-
Is it possible to access the current memory usage values for the running application, from within the applications own code? I have had a hard time finding documentation on this. At first I tried to use the performance monitor classes, but I can't see a way to load up a performance monitor for the current process. Is this possible in .NET? I appreciate any replies.
long memUsed = System.GC.GetTotalMemory(true/false); True if you want to force a garbage collection before computing the memory used.
-
long memUsed = System.GC.GetTotalMemory(true/false); True if you want to force a garbage collection before computing the memory used.
-
Hmm...I was looking for a finer grained level of detail....the kind of info you can get from perfmon. Physical and Virtual memory usage, garbage collection counts, propmotions, etc.
Does http://www.aspheute.com/english/20000809.asp help?
-
Well, not really. I know how performance counters work, how to create them, etc. etc. My question is how to I get a performance counter, in say the .NET GC category, for the "current", that beeing the key word, process. The process that I'm actually instantiating the performance counter from? This is not a web application, its a windows forms application. I'm not trying to recreate the perfmon application, I don't want to view performance counters for "other" processes....I want to view them for the process from which I instantiate the counter. I've looked and looked, but there doesn't seem to be a site on the net or a single word in the .NET documentation that says how to get a counter for the current app, the one that instantiates the performance counter itself. The current instance is what I'm inclined to call it, but there doesn't seem to BE a current instance, only global instances and specific instances for some apps.