How to get current CPU and RAM usage in C++?

tunnuz picture tunnuz · Jan 26, 2009 · Viewed 49.8k times · Source

is it possible, in C++, to get the current RAM and CPU usage? Is there a platform-indepentent function call?

Answer

Kosi2801 picture Kosi2801 · Jan 26, 2009

Sadly these things rely heavily on the underlying OS, so there are no platform-independent calls. (Maybe there are some wrapper frameworks, but I don't know of any.)

On Linux you could have a look at the getrusage() function call, on Windows you can use GetProcessMemoryInfo() for RAM Usage. Have also a look at the other functions in the Process Status API of Windows.