All Posts by Date or last 15, 30, 90 or 180 days.
also by Lloyd: diglloyd.com photography and WindInMyFace.com
Thank you for purchasing through links and ads on this site.
OWC / MacSales.com...
diglloyd Deal Finder...
Buy other stuff at Amazon.com...
Get up to 16x more storage and 2x the speeds of the original drive
Handpicked deals...
$470 $470
SAVE $0

$470 $470
SAVE $0

$4499 $2999
SAVE $1500

$200 $165
SAVE $35

$398 $248
SAVE $150

$4999 $4499
SAVE $500

$2199 $1999
SAVE $200

$2799 $2349
SAVE $450

$120 $120
SAVE $0

$3099 $2499
SAVE $600

$249 $149
SAVE $100

$100 $60
SAVE $40

$2844 $2297
SAVE $547

$1099 $1019
SAVE $80

$899 $530
SAVE $369

$1199 $1099
SAVE $100

$1999 $1379
SAVE $620

$999 $949
SAVE $50

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 QuickLookSatellite was opening every JPEG file that I created and keeping them all openforever! A newbie programming bug of failing to close a file after opening it. More Apple 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 git and ssh abort. And so on. Why QuickLookSatellite 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!).

When files are open (“in use”), Trash cannot be emptied

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 lsof command in Terminal (use 'sudo' if you want to see all files, not just ones viewable by your login user). The lsof 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 QuickLookSatellite, 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 QuickLookSatellite, 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: QuickLookSatellite. Knowing this, I found a solution. For example, here is a list of 254 open files (via lsof | grep jpg) that QuickLookSatellite 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.

Closing open files by killing QuickLookSatellite

Two methods.

Using Activity Monitor

To fix this problem without rebooting:

  1. Open Activity Monitor.
  2. Enter "quick" in the search box; this will list just the matching process names.
  3. Kill both QuickLookSatellite 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).

How to kill QuickLookSatellite in Activity Monitor

In Terminal

Terminal (command line) is easy and the solution can even be made into alias (shortcut) like killQL 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 ~/.bash_profile file so the alias (shortcut) killQL 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"

 


MacPerformanceGuide.com
View all handpicked deals...

Dell Vostro 3470 Small Desktop Computer
$470 $470
SAVE $0

diglloyd.com | Terms of Use | PRIVACY POLICY
Contact | About Lloyd Chambers | Consulting | Photo Tours
Mailing Lists | RSS Feeds | Twitter
Copyright © 2019 diglloyd Inc, all rights reserved.
Display info: __RETINA_INFO_STATUS__