C# Get used memory in %

You could use GetPerformanceInfo windows API, it shows exactly the same values as Windows Task Manager on Windows 7, here is the console application that get’s available physical memory, you could easily get other information that GetPerformanceInfo returns, consult MSDN PERFORMANCE_INFORMATION structure documentation to see how to calculate value in MiB, basically all SIZE_T values … Read more

“Access to the registry key ‘Global’ is denied” when accessing performance counters

I found the solution. Whereas various links around the Internet tell you to use the identity IIS APPPOOL\DefaultAppPool, that is NOT the full story. That will only work if you are in fact assigning your applications to an app pool named “DefaultAppPool”. This link at ServerFault has the answer. You must use the name of … Read more

What is the correct Performance Counter to get CPU and Memory Usage of a Process?

From this post: To get the entire PC CPU and Memory usage: using System.Diagnostics; Then declare globally: private PerformanceCounter theCPUCounter = new PerformanceCounter(“Processor”, “% Processor Time”, “_Total”); Then to get the CPU time, simply call the NextValue() method: this.theCPUCounter.NextValue(); This will get you the CPU usage As for memory usage, same thing applies I believe: … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)