Quite often when browsing the Web, you might find yourself with multiple browser windows and tabs open. This may be convenient for workflow, but if a problem occurs where Safari stalls or otherwise runs slow, or causes your Mac to use excessive CPU percentage and run hot, then while you might be tempted to simply force-quit Safari and relaunch it, you might also benefit from knowing which Safari process is causing the problem.
Safari isolates your various Web pages from each other by hosting them in separate running processes called “Safari Web Content,” and while you will see these in Activity Monitor, determining which is responsible for a particular window may be a touch difficult. By default, the only determining factor for this is to hover your mouse over each Safari Web Content listing, where you can see the Web pages hosted in it show up as a small yellow tooltip window.
While this has its uses, it may only be good when you have only a few Web pages open and can easily peruse through them. If you have more windows open, you might end up investigating many processes to determine which is the one you are looking for.
To make this easier, you can use Safari’s hidden Debug menu to append the process ID for that window to the window’s name.
- Enable the Debug menu by running the following command in the OS X Terminal:
defaults write com.apple.Safari IncludeInternalDebugMenu 1
- Re-launch Safari to access the Debug menu
- Go to Debug > Miscellaneous Flags, and select “Show Web Process IDs in Page Titles”
Select this option in the Debug menu to show Web Process IDs for each Safari window.
When done, this should make the process ID show wherever the page title is displayed. In some versions of Safari this will be at the top of the window, but in other versions Apple has done away with this in an effort to maximize real estate for Web content. However, you can still determine the window’s process ID by either right-clicking the Dock icon or choosing the Window menu from within Safari. Either of these should show you the Safari windows (with the foremost one being checked), and allow you to see the Process ID for each window. You can then locate these in Activity Monitor to force-quit or otherwise manage them.
To disable the Debug menu in Safari, you can run the following command in the Terminal, followed by re-launching Safari:
defaults delete com.apple.Safari IncludeInternalDebugMenu
UPDATE: Fixed Terminal command syntax.