Improving the world one bad analogy at a time

Date:September 18, 2003 / year-entry #70
Tags:other
Orig Link:https://blogs.msdn.microsoft.com/oldnewthing/20030918-00/?p=42423
Comments:    9
Summary:One thing I am known for at Microsoft is my frequent use of bad analogies. Everybody else at work has had to suffer; now it's your turn. Why are there so many copies of svchost.exe running? What is svchost.exe anyway? Traditionally, each service runs in its own process. When you are developing and testing your...

One thing I am known for at Microsoft is my frequent use of bad analogies. Everybody else at work has had to suffer; now it's your turn.

Why are there so many copies of svchost.exe running? What is svchost.exe anyway?

Traditionally, each service runs in its own process. When you are developing and testing your service, having it in its own process makes debugging a lot easier.

But if you look at your list of services (in Computer Management, Services), you can see that if each one got its own process you'd sure have a whole lot of processes lying around. Since there is a cost to each process merely for existing, having so many processes running would be a waste, since many services are used only sporadically. Tapisrv, for example, is active only when you are doing things with your modem.

For performance reasons, groups of services are thrown together and run in a shared process called svchost. Sort of like a reality TV show, but without the voting.

This means that if you see a copy of svchost.exe going a bit haywire in Task Manager, you can't really tell which service inside it is responsible. For performance reasons, groups of services are thrown together and run in a shared process called svchost. Sort of like a reality TV show. Knowledge Base article 314056 describes how you can dig into each svchost to see which services are running inside it. This will at least narrow the problem down to a subset of all the services.


Comments (9)
  1. _brG_ says:

    i think its about time u went on vacation ;)

  2. C-J Berg says:

    LOL :)

    The wonderful freeware utility Process Explorer by Mark Russinovich (SysInternals) should not go unnoticed in this context (open the properties for svchost.exe, and the Services tab will show you all registered services in the process).

    http://sysinternals.com/ntw2k/freeware/procexp.shtml

  3. Jeremy Gray says:

    And if it isn’t obvious yet, the current mechanism must change, lest we will all end up infected with worms that actually run themselves as services under svchost so that they can sneak through programs like ZoneAlarm which because of this mechanism must grant unnecessary permissions to svchost on account of having no clue as to what is running under that .exe at any given time.

    We have multiple GHz machines with hundreds of megabytes of memory. Soon enough we will have desktop 64 bit processors and operating systems to match. We can afford to have a few more unique processes idling around in memory, and, from a security perspective, we’re long past the realm of excuses.

  4. Eyal says:

    Altough I agree with Jeremy that the current mechanism much change, i disagree that having more processes is the right way to do it. I think the way to handle this is to let the (e.g.) Tapi service register itself within svchost.exe (so the service will "appear" running), but when it is actually needed, svchost will execute the actual TapiSrv.exe and forward all requests to it. A service will be able to shutdown it’s process and again register for "wake up" when it isn’t uses for sometime.
    Just a thought.

  5. Fred says:

    What does it have to do with reality TV show? The fact that they throw a bunch of services into one svchost process instance?

  6. Mike Dimmick says:

    It also means that once a service loads a DLL, that DLL can’t be unloaded – and hence replaced – until all the services in that host process terminate and the host process quits.

    This is why a new MDAC version almost always requires a reboot on Windows 2000 – because some part of Windows (might be IIS) running as a service uses some part of MDAC, and you can’t kill it off.

  7. It is partly because of issues like this that I sincerely regret that the human race hasn’t yet been able to open up the colonization of space. Then we could just go and live on the far side of Jupiter and stop worrying.

  8. The Svchost.exe file is located in the %SystemRoot%System32 folder. At startup, Svchost.exe checks the services part of the registry to…

Comments are closed.


*DISCLAIMER: I DO NOT OWN THIS CONTENT. If you are the owner and would like it removed, please contact me. The content herein is an archived reproduction of entries from Raymond Chen's "Old New Thing" Blog (most recent link is here). It may have slight formatting modifications for consistency and to improve readability.

WHY DID I DUPLICATE THIS CONTENT HERE? Let me first say this site has never had anything to sell and has never shown ads of any kind. I have nothing monetarily to gain by duplicating content here. Because I had made my own local copy of this content throughout the years, for ease of using tools like grep, I decided to put it online after I discovered some of the original content previously and publicly available, had disappeared approximately early to mid 2019. At the same time, I present the content in an easily accessible theme-agnostic way.

The information provided by Raymond's blog is, for all practical purposes, more authoritative on Windows Development than Microsoft's own MSDN documentation and should be considered supplemental reading to that documentation. The wealth of missing details provided by this blog that Microsoft could not or did not document about Windows over the years is vital enough, many would agree an online "backup" of these details is a necessary endeavor. Specifics include:

<-- Back to Old New Thing Archive Index