Microsoft IE8 and Google Chrome - Processes are the New Threads
I happened to install Google Chrome (Alpha) the same day I installed Internet Explorer 8 (Beta). I noticed immediately, as I'm sure many of you have, that both browsers isolate tabs in different processes.
Unix folks have known about the flexibility of forking a process forever. In Unix, fork() is just about the easiest thing you can do. Also, fork()ing in Unix will copy the whole process and all variables into a new space. Everything after the fork happens twice. Multitasking made easy.
In Windows, you call CreateProcess() and you don't get a copy or clone. You just start up a whole new universe, starting from the very beginning - NOT from the call to CreateProcess().
What processes in Windows and Unix do have in common is that they each get their own protected virtual memory space. They are all alone and isolated. If a process crashes it's less of a crisis than if a thread within a process crashes.
(In .NET, AppDomains are like mini-processes, but they just aren't as completely isolated as a process is, so you can still bork an AppDomain enough that the whole process dies.)
Why does all this matter? Well, back in the day, most folks on Windows would recommend that developers interested in multi-tasking use threads. There's even been talk about fibers (really tiny threads within threads...like superstrings ;) ) However, darnnit, processes are easy.
Ah! But they're slow! They're slow to start up, and they are slow to communicate between, right? Well, kind of, not really anymore. There's this thing called Moore's Law that keeps marching on. Making a new process and talking to it in any of the myriad IPC (Inter-process Communication) methods available just isn't that much of a problem these days. Just open up Process Explore and enter "Tree View" sometime to see how many programs you use every day are actually multiple .exe's working together.
You can learn more about IE8 and how their multiple-process model works in both IE7 and IE8. (IE7 had this process isolation feature also...except one tab per security zone.)
You can learn more about Chrome and how they talk between their multiple "Render" processes in this architectural overview. They are using named pipes if you were wondering how Chrome talks to itself.
Tab/Process Isolation
I'll open up an instance of IE8 and open one tab with cnn.com and other with hanselman.com. I'll do the same with Google Chrome. Here's what Process Explorer shows.
Why are some of the processes brown? Those are jobs, a new kind of process added in Windows 2000. Jobs are made with CreateJobObject and AssignProcessToJobObject. You can also get a Job using CreateProcess as unless you specify the CREATE_BREAKAWAY_FROM_JOB flag. Jobs in Windows can be controlled as a group and resource limits can be set on them. You can learn more about Jobs and why they can be more secure up on MSDN.
Crash Protection
The whole point of having more than one process for a browser is for crash protection. I've had every browser I've ever used crash in one tab while I was hoping to keep my other 49 tabs open.
Let's blow away some processes manually and see what the browsers do. I'll blow away the non-job process for Chrome.exe.
Looks like that process hosted Flash. See how the Flash object has been replaced on the cnn.com home page with a sad puzzle piece? Cool. Chrome hosts plugins in their own process also.
Lets blow away another Chrome.exe process. Ah, looks like that particular process was rendering hanselman.com. It's been replaced by a sad-page icon.
_3.png)
OK, let's blow away an IE8 process....
Ah, looks like the FIRST time a page crashes in IE8, it dumps the process, the tab disappears, then the tab comes back automatically to try to put the user where they were before. I'll kill the new process...
Looks like IE8b2 will only try a few times to automatically restore the bad tab then it gives up and gives its equivalent sad-tab and says "the website continues to have a problem." Also cool. This beta includes an option to turn "automatic crash recovery" off or on.
If the parent process dies (or, in this case, I kill it myself!) then I'll get a dialog from IE8 offering to restore the last session.
I'll get this similar message in Google Chrome.
Very cool. Now I have two browsers that I can open up a buttload of tabs in and not worry about maxing-out process limits or having one bad tab messing up the whole bunch.
PS: If you are poking around in Chrome, try visiting pages like: "about:network", "about:stats", "about:dns" and "about:memory"
About Scott
Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.
About Newsletter



Disclaimer: Everything in this post is pure conjecture by me, done by simply poking around my system and talking to myself. I don't work for the Live Mesh team, nor do I know anyone on the team. Anyone could have written this.