Question

On windows you can see pull up the task manager or Get-Process in powershell to get a list of running processes along with their memory and cpu usage.

You can also (on windows 8 or Get-Service in powershell) view all running services. Yet for services you do not get any of those numbers.

From my developer point of view this always seemed a bit odd. Sure, a service requires a bunch more deployment effort and is awkward to code and debug, but otherwise it's just a program same as any other.

I'm sure there's a good reason for why services do not have those numbers, one that probably has something to do with how windows runs services. What is that reason?

Was it helpful?

Solution

There is a service host process "svchost.exe" that can start/handle multiple services. Since resource consumption is generally measured by the operating system at the process level, services that have been started by the same host process will all show up as usage by that process.

If you look in the 'services' area of the Control Panel and look for the program that starts a service, you'll find most of the Windows services all use "svchost.exe" with different parameters to start it.

Task Manager shows multiple instances of svchost.exe so it is possible to isolate a specific service to one instance of svchost.exe but you'd need to know which instance is serving just the service of interest. You could use PowerShell to start the service through svchost.exe but hang onto the process ID and then add the Process ID column in Task Manager so you could see memory/CPU usage.

OTHER TIPS

While I haven't been able to find a way to view the memory usage of any one individual service, you can view which services are running in each instance of svchost by using tasklist /svc in the command line, and the memory usage of each individual svchost by looking at the Process ID.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top