Click here to Skip to main content
15,746,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Good Evening,

I am writing a C program and need to get memory info (Size and Usage),
also I need to know the CPU usage amount.

Do we have functions that returns these results?


You could try google. I found this CodeProject article with the search phrase, "C++ get cpu load":

Get CPU Usage with GetSystemTimes[^]

Share this answer
Espen Harlinn 10-Jan-11 15:14pm    
5+ Can't help noticing that a certain outlawed programmer never seems to sleep either :)
Sandeep Mewara 11-Jan-11 7:41am    
Comment from OP:
Thanks john,

I am looking for one function that will give one value,
I want to apply a load balancing idea in a parallel application so need to see how much each machine is busy and has empty memory.
Another alternative is to use performance counters. Here is a small example:
Windows C++ Get CPU and Memory Utilisation With Performance Counters[^]

And one from CP
An Introduction To Performance Counters[^]

Espen Harlinn
Share this answer
google MEMORYSTATUSEX for documentation
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900