is it possible, in C++, to get the current RAM and CPU usage? Is there a platform-indepentent function call?
Press Ctrl + Shift + Esc to launch Task Manager. Or, right-click the Taskbar and select Task Manager. Select the Performance tab and click Memory in the left panel. The Memory window lets you see your current RAM usage, check RAM speed, and view other memory hardware specifications.
Using Task Manager to Check CPU UsageStart by pressing CTRL + Shift + Esc on your keyboard. In the following window, click Task Manager. While in Task Manager, click the Performance tab. Here in the Performance tab, you can see how much of the CPU the computer is currently using.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With