File handle leak?
seancorfield opened this issue · comments
If I try to process a long list of files, Slamhound fails after about a dozen files with "Too many open files in system" which suggests it isn't closing all the files it opens:
lein run -m slam.hound `find src -name '*.clj'`
It may be this:
(defn reconstruct [filename]
;; Reconstructing consists of three distinct phases:
;; asploding, regrowing, and stitching.
(with-regrow-cache
(-> (io/reader filename)
asplode
regrow
stitch-up)))
I think this should be:
(defn reconstruct [filename]
;; Reconstructing consists of three distinct phases:
;; asploding, regrowing, and stitching.
(with-regrow-cache
(with-open [rdr (io/reader filename)]
(-> rdr
asplode
regrow
stitch-up))))
I'll fork the repo and see if I can verify this fix and send a PR.
Suggestion here is only a partial fix. PR #77 has a fully tested fix.