Browse files

Call System/gc before deleting files recursively.

Calling System/gc can help release files on windows.
It will hopefuly help with issues such as #252 and #309.

I wasn't able to reproduce those two issues on Windows
Vista, but I have experienced a related problem when
running the leiningen test suite when some jar files
failed to be deleted. Calling System/gc resolved the
issue in that case.
  • Loading branch information...
mtyaka committed Nov 12, 2011
1 parent 04061ff commit 32ebf41f23b0fdc5b35991ab3f04a506ac0934c5
Showing with 1 addition and 4 deletions.
  1. +1 −0 src/leiningen/util/file.clj
  2. +0 −4 test/leiningen/test/deps.clj
@@ -11,6 +11,7 @@
"Delete file f. If it's a directory, recursively delete all its contents.
Raise an exception if any deletion fails unless silently is true."
[f & [silently]]
+ (System/gc) ; This sometimes helps release files for deletion on windows.
(let [f (file f)]
(if (.isDirectory f)
(doseq [child (.listFiles f)]
@@ -51,10 +51,6 @@
(let [rel-repo-snaps-dep (assoc pr :dependencies [slamhound])]
(is (thrown? Exception (with-no-log (deps rel-repo-snaps-dep))))))
- ;; This gc call is a workaround for a windows specific problem
- ;; where jars fail to get deleted. An explicit call to gc seems
- ;; to solve the issue.
- (System/gc)
(delete-file-recursively (:library-path sample-project) :silently))))
(def native-lib-files-map

0 comments on commit 32ebf41

Please sign in to comment.