# How can I free files that are in use by quicklook?

I have a couple pictures I was looking through and deleting stuck in my trash (Mac OS X 10.6 latest) and finder tells me they are in use when I try to delete them.

I looked around online and found the lsof command in terminal (type lsod with a space, drag the file onto terminal, press enter) it told me the file was in use by:

 COMMAND     PID     FD
Finder      7747    txt
Finder      7747    13r
mdworker    8685    txt
quicklook   8822    13r
quicklook   8822    14r


any idea what I can do about this? (other than restarting, this happens to me quite a bit), I'm wondering if this could be a bug as well.

Thanks for any help.

Running the command qlmanage -r in Terminal forces QuickLook to reload.

Hence releasing all locked files, now you will be able to empty your trash successfully.

• Loading multiple items and even trying to kill the pid doesn't work but this command does it every time. Should be marked as the correct answer -JH – John Apr 2 '16 at 2:51

Quick Look holds on to two items at a time. Annoying, but that can be used to your advantage. Simply select two new new files in Quick Look, and it will purge the old ones from its memory, allowing you to empty the trash.

Did you try Secure Empty Trash?

Right-click on the Dock, and hold the Command key. Then click on Secure Empty Trash. It works for me, sometimes.

Else, open up Terminal.app and type kill -9 <PID>

• Wouldn't it be bad to kill finder? – user32791 Mar 31 '10 at 3:12
• It shouldn't be bad. If you're uncomfortable using "kill", try holding Option while right-clicking on the Finder icon in the Dock. Then select the "Relaunch" menu item. – Lawrence Velázquez Mar 31 '10 at 5:42

Try first to reboot the machine. Otherwise, you'll have to force terminate the processes.

• Rebooting works for sure – user32791 Mar 31 '10 at 3:11

Is it a bug? Kinda. In a perfect world, programs like quicklook wouldn't hold onto files, or would release them when notified that they're about to be deleted.

In this world, there's nothing wrong with terminating the offending programs (quicklook may be enough, the Finder doesn't usually cause problems that last more than a few seconds).

Either kill them in the Terminal, or use Activity Monitor to signal them to quit. Most programs, including the Finder, will relaunch automatically. kill -9 or Force Quit are overkill, unless they don't listen to the nice signal.

If you're still unable to delete them, logging out and back in is a quicker alternative to restarting that will release the files in the majority of cases.

You could just use rm to delete the file without killing anything. Just put in rm on Terminal, put in a space, and drag the file you want to delete onto the window