compile leaks files

Description

clojure's compile function leaks file descriptors, i.e. it relies on garbage collection to close the files. I'm trying to use boot [1] on windows and ran into the problem, that files could not be deleted intermittently [2]. The problem is that clojure's compile function, or rather clojure.lang.RT.lastModified() relies on garbage collection to close files. lastModified() looks like:

Here's the stacktrace from file leak detector [3]:

Cause: getLastModified() opens the URLConnection's InputStream but does not close it.

Approach: On Stackoverflow [4] there's a discussion on how to close the URLConnection correctly.

On non-Windows operating systems this shouldn't be much of a problem. But on windows this hurts very much, since you can't delete files that are opened by some process.

Patch: clj-1659-v3.patch

Screened by: Alex Miller

[1] http://boot-clj.com/
[2] https://github.com/boot-clj/boot/issues/117
[3] http://file-leak-detector.kohsuke.org/
[4] http://stackoverflow.com/questions/9150200/closing-urlconnection-and-inputstream-correctly

Environment

None

Attachments

3

Activity

Show:

import August 10, 2015 at 7:35 PM

Comment made by: edannenberg

Done. CLJS-1416

Alex Miller August 10, 2015 at 6:30 PM

Looks like similar problem in CLJS to me - I would open a ticket there.

import August 10, 2015 at 5:59 PM

Comment made by: edannenberg

Former user August 10, 2015 at 5:51 PM

This is hard to tell without a stacktrace...

import August 10, 2015 at 5:46 PM

Comment made by: edannenberg

I attached the file leak detector and ran boot with clojure 1.7 and 1.8-alpha4, the stacktraces for both are a bit different but from what i can tell the leak cause is still the same and looking very similiar to the stacktrace posted in the issue description. I do however see the cljs compiler further down in the stacktrace.

Should i open an issue on CLJS tracker?

Completed

Details

Assignee

Reporter

Approval

Ok

Patch

Code

Priority

Affects versions

Fix versions

Created February 16, 2015 at 9:08 AM
Updated August 10, 2015 at 7:35 PM
Resolved August 10, 2015 at 7:35 PM