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

后端 未结 9 975
后悔当初
后悔当初 2020-12-01 06:44

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

9条回答
  •  情歌与酒
    2020-12-01 07:14

    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.

提交回复
热议问题