OS X Bug: QuickLookSatellite Opens Files and Never Closes Them, Causing Wide-Ranging Errors
Update 27 May: Apple Mail has a similar bug.
Update 29 May: example listing and Finder dialog added.
A few days ago, my Mac Pro started acting funny: my testing java web server kept quitting. Other things started misbehaving too, with error messages about not being able to open a file, or ssh failing to open a socket.
The java web server could not get a file or socket to open, so it would quit. I would restart it, and it would die after a few pages had loaded. This was very puzzling, since OS X has an ample limit for file descriptors and sockets.
Here is what is happening: the background process ! A newbie programming bug of failing to close a file after opening it. More was opening every JPEG file that I created and keeping them all open—foreverApple Core Rot.
With a monotonically increasing number of open files (see this listing for an example after just an hour or so), OS X runs out of file descriptors eventually, and then all sorts of weird things start happening. Servers quit, strange error messages appear, even command line tools like and abort. And so on. Why does this is unclear—perhaps because they are new files and it is trying to be “smart” and take a peek at them for indexing. But it never closes the files, thus chewing up a file descriptor for every file.
One obvious symptom of the problem is that when these files are put into the trash, the Finder posts an error alert saying it cannot empty the trash because the file is open (an error alert for every file!).

The when or why—what provokes it, is unclear. Newly created files? Using Spotlight in a certain way? Selecting and moving or copying? Simply opening a folder with the new files? Probably most users will not encounter this issue, or so MPG thinks. But there could be many other situations that cause it to happen.
QuickLook is so buggy that it even keeps temporary files and network files open. Temp files are files a program creates and disposes of (or thinks it has). These files are not displayed by the Finder, so you might not realize that 5 or 10 or 200 files are open. No wonder OS X runs out of file descriptors!
QuickLook 18320 lloyd 11r REG 1,4 534938 23703321 /Users/lloyd/Desktop/crop_tmp1365237595
QuickLook 18320 lloyd 12r REG 1,4 534938 23703321 /Users/lloyd/Desktop/crop_tmp1365237595
Detecting and counting open files
To see all open files, use the
command in Terminal (use 'sudo' if you want to see all files, not just ones viewable by your login user). The command will dump a fairly long list of open files, which is normal:diglloydMP:MPG lloyd$ lsof
To show only the files are open by
, but excluding files expected to be open:diglloydMP:MPG lloyd$ lsof | grep Quick | grep -v -e /System -e /Library -e /private -e /dev -e /usr -e KQUEUE -e cwd
To count the number of files open by
, but excluding files expected to be open:diglloydMP:MPG lloyd$ lsof | grep Quick | grep -v -e /System -e /Library -e /private -e /dev -e /usr -e KQUEUE -e cwd | wc -l
# not as complicated as it looks; the -e arguments are to omit files that are normally open by QuickLookSatellite
In my case, I observed a huge list of JPG files that I recognized as files I had recently created as part of my work. The culprit keeping all those files open: list of 254 open files (via lsof | grep jpg) that is keeping open after just a single page I was preparing (I do many more each day). It has other jpg files open for who knows what reason; just seemingly random open files.
. Knowing this, I found a solution. For example, here is aClosing open files by killing QuickLookSatellite
Two methods.
Using Activity Monitor
To fix this problem without rebooting:
- Open .
- Enter "quick" in the search box; this will list just the matching process names.
- Kill both processes.
When a process is killed, the OS cleans up the mess (files, memory, sockets, etc). So instantly the absurd number of open files are closed—problem solved. Mysterious problems go away, the Finder can empty the trash, etc. However, if the system does get into this state, MPG recommends quitting and reopening any app that had misbehaved; it could have lingering issues because it did not handle the failure well (very unlikely to ever be tested for).

In Terminal
Terminal (command line) is easy and the solution can even be made into alias (shortcut) like
or similar. Shown below are processes before and after killing QuickLookSatellite:diglloydMP:DIGLLOYD lloyd$ ps -ef | grep Quick 501 17488 1 0 8:13AM ?? 0:00.45 /System/Library/Frameworks/QuickLook.framework/Resources/quicklookd.app/Contents/MacOS/quicklookd 501 18320 1 0 8:24AM ?? 0:00.11 /System/Library/Frameworks/QuickLook.framework/Versions/A/Resources/quicklookd.app/Contents/XPCServices/QuickLookSatellite.xpc/Contents/MacOS/QuickLookSatellite 501 21160 1 0 8:58AM ?? 0:01.27 /System/Library/Frameworks/QuickLook.framework/Versions/A/Resources/quicklookd.app/Contents/XPCServices/QuickLookSatellite.xpc/Contents/MacOS/QuickLookSatellite 501 24167 39289 0 9:45AM ttys003 0:00.00 grep Quick
diglloydMP:DIGLLOYD lloyd$ killall -9 -v QuickLookSatellite
diglloydMP:DIGLLOYD lloyd$ ps -ef | grep Quick 501 17488 1 0 8:13AM ?? 0:00.45 /System/Library/Frameworks/QuickLook.framework/Resources/quicklookd.app/Contents/MacOS/quicklookd 501 24208 39289 0 9:45AM ttys003 0:00.00 grep Quick
Or, make an alias in
file so the alias (shortcut) can be typed in Terminal:alias killQL="killall -9 -v QuickLookSatellite"
Or, use a short shell script (save as executable file) in your PATH:
#!/bin/sh # save this as an executable in shell PATH alias countDubiousQL="lsof | grep Quick | grep -v -e /System -e /Library -e /private -e /dev -e /usr -e KQUEUE -e cwd | wc -l" alias showDubiousQL="lsof | grep Quick | grep -v -e /System -e /Library -e /private -e /dev -e /usr -e KQUEUE -e cwd" function QL_DubiousCount() { DUBIOUS_COUNT=`countDubiousQL` echo $DUBIOUS_COUNT dubious files $1: showDubiousQL } QL_DubiousCount "BEFORE" echo "" killall -9 -v QuickLookSatellite echo "" QL_DubiousCount "AFTER"