views:

94

answers:

3

Under WindowsCE, C++ project, I'd like to get CPU utilization and memory allocation data real time - for logging and troubleshooting. Is there a library or activeX available that i could include in my code and use [without bringing my process to a halt, preferably], anyone knows?

thanks much for any insight!

O.

+1  A: 

For CPU usage, you can call GetThreadTimes.

SLaks
I'm guessing he means current total CPU utilization (i.e. for the whole OS rather than just one thread).
MusiGenesis
yes, i need total, for the whole system - I have more than one processes that are mine, and i want to know about all of them (from within one 'master' proc)thanks!
Oleg Ivanov
+1  A: 

If you are running on an arm based system (don't know enough about x86 systems) then you need to calculate cpu load on your own by spawning an idle thread and check how much time it consumes.

You can use the ToolHelpApi (a nice blog post that demonstrates this) to extract more information about processes.

Shaihi
yes, it's arm-based; thanks much for the link, very useful!
Oleg Ivanov
+1  A: 

It's not entirely clear whether you're trying to have the process monitor itself, or have one process monitoring another. In the first case, you want to put your monitoring in a separate thread to keep it from bringing the rest of the program to a halt.

SLaks has already covered getting CPU usage, so I won't repeat that.

You can get information about the blocks of memory allocated to a process with VirtualQuery or VirtualQueryEx (VirtualQuery to query the process' own memory, VirtualQueryEx to look at another process). At least for the first attempt, I'd count the private pages as the ones allocated by a particular process.

Jerry Coffin