Process CPU and memory usage

Process CPU and memory usage

Post by Sergey Karpo » Wed, 13 Nov 2002 01:50:31



Simple API:
Look for:
GetProcessTimes(...)
VirtualQueryEx(...) /* This call is expensive */

About WMI API and
 Performance Monitor Counters
You can read
Programming Server-Side Applications for Microsoft Windows 2000
-- Jeffrey Richter, Jason D. Clark

Good luck.
Sergey Kaprov.


Quote:> Hi everybody

> I need to write a code to monitor CPU and memory usage for a process
> (similar to the info given by task manager) in win2000.

> I really can't find how to do this... any idea?

> TIA

> Cheers

> Fernando

 
 
 

Process CPU and memory usage

Post by Fernando Marott » Wed, 13 Nov 2002 01:00:48


Hi everybody

I need to write a code to monitor CPU and memory usage for a process
(similar to the info given by task manager) in win2000.

I really can't find how to do this... any idea?

TIA

Cheers

Fernando

 
 
 

Process CPU and memory usage

Post by shur » Wed, 13 Nov 2002 02:48:59


For NT/Win2K/XP there are very simple way:

- For CPU usage:
  SYSTEM_PROCESSOR_TIMES SysTime;
  NtQuerySystemInformation( SystemProcessorTimes,
                            &SysTime, sizeof(SysTime), NULL );

- For Memory usage:
  VM_COUNTERS VmCounters;
  NtQueryInformationProcess( NtCurrentProcess(),
                             ProcessVmCounters,
                             &VmCounters, sizeof(VmCounters), NULL );

Unfortunatly I dont know exactly how to get such info for Win9x.


> Hi everybody

> I need to write a code to monitor CPU and memory usage for a process
> (similar to the info given by task manager) in win2000.

> I really can't find how to do this... any idea?

> TIA

> Cheers

> Fernando

 
 
 

Process CPU and memory usage

Post by Andrey A. Belki » Wed, 13 Nov 2002 18:54:52


For memory:
GlobalMemoryStatus(...)

It works in
  Windows NT/2000/XP: Included in Windows NT 3.1 and later.
  Windows 95/98/Me: Included in Windows 95 and later.

--
Andrey A. Belkin


> For NT/Win2K/XP there are very simple way:

> - For CPU usage:
>   SYSTEM_PROCESSOR_TIMES SysTime;
>   NtQuerySystemInformation( SystemProcessorTimes,
>                             &SysTime, sizeof(SysTime), NULL );

> - For Memory usage:
>   VM_COUNTERS VmCounters;
>   NtQueryInformationProcess( NtCurrentProcess(),
>                              ProcessVmCounters,
>                              &VmCounters, sizeof(VmCounters), NULL );

> Unfortunatly I dont know exactly how to get such info for Win9x.


> > Hi everybody

> > I need to write a code to monitor CPU and memory usage for a process
> > (similar to the info given by task manager) in win2000.

> > I really can't find how to do this... any idea?

> > TIA

> > Cheers

> > Fernando

 
 
 

Process CPU and memory usage

Post by arkady » Thu, 14 Nov 2002 18:50:42


Look at "
Finding Leaks and Bottlenecks with a Windows NT PerfMon COM Object"
in MSDN how to use PHD for that.
Arkady


Quote:> Hi everybody

> I need to write a code to monitor CPU and memory usage for a process
> (similar to the info given by task manager) in win2000.

> I really can't find how to do this... any idea?

> TIA

> Cheers

> Fernando