Is there a way I can find what file handles emacs has open, and close these references? Or even better, find where they are being open?
Emacs is keeping handles to a large number of files (a leak) that I don't have corresponding buffers to. My standard method of closing a buffer has been using the kill-buffer command.
Context:
I am having a reoccurring issue, where after a day or two of being open I can no longer do any file operations in emacs, due to a "Too many open files" error when creating a pipe. I am on OSX 10.10.4, Emacs 25.0.50 installed with homebrew.
Here is a sample of emacs' open files according to Activity Monitor (double click on emacs and select "Open Files and Ports").
/Users/Ash/Dropbox/org /Users/Ash/Dropbox/org /Users/Ash/Dropbox/org /Users/Ash/Dropbox/org /Users/Ash/Documents/workspace/roboclub/Federation-Place /Users/Ash/Documents/workspace/roboclub/Federation-Place /Users/Ash/Documents/workspace/roboclub/Federation-Place /Users/Ash/Documents/workspace/roboclub/Federation-Place/web/site /Users/Ash/Documents/workspace/roboclub/Federation-Place/web/site/src/javascript/status /Users/Ash/Dropbox/org /Users/Ash/Dropbox/org /Users/Ash/Dropbox/org /Users/Ash/Dropbox/org /Users/Ash/Documents/workspace/roboclub/Federation-Place/web/site/src/javascript/status /Users/Ash/Documents/workspace/roboclub/Federation-Place /Users/Ash/Documents/workspace/roboclub/Federation-Place /Users/Ash/Documents/workspace/roboclub/Federation-Place /Users/Ash/Documents/workspace/roboclub/Federation-Place/web/site/src/javascript/status /Users/Ash/Documents/workspace/roboclub/Federation-Place/web/site/src/javascript/status /Users/Ash/Documents/workspace/roboclub/Federation-Place/web/site/src/javascript/status /Users/Ash/Documents/workspace/roboclub/Federation-Place/web/site/src/javascript/status /Users/Ash/Documents/workspace/roboclub/Federation-Place/web/site/src/javascript /Users/Ash/Documents/workspace/roboclub/Federation-Place/web/site/src/javascript /Users/Ash/Documents/workspace/roboclub/Federation-Place/web/site/src/javascript /Users/Ash/Documents/workspace/roboclub/Federation-Place/web/site/src/javascript There are actually many more files open, but you can see that they are being repeated. (Also these are folders, not sure why that is).
Update
The following are my file limits:
$ ulimit -n 4096 $ sysctl -a | grep files kern.maxfiles: 20480 kern.maxfilesperproc: 10240 kern.num_files: 4496 And my open files:
$ lsof | awk '{print $1 "-" $2}' | sort | uniq -c | sort -nr | head -10 728 Google-345 508 Google-551 430 Mail-353 418 Skype-12098 356 Dock-361 350 Emacs-8847 207 Dropbox-637 176 Google-22455 176 Google-21229 165 Google-26072 Emacs is the only program having issues, yet doesn't seem to have a comparatively high file count.