Fork me on GitHub
#hoplon
<
2015-10-11
>
Doug Kirk01:10:05

Java added syntax sugar for doing this with try(stream) { ... } and the above Scala snippet is what we use at my day job

Doug Kirk01:10:24

I don't know what the equivalent in Clojure is.

micha01:10:49

in clojure you'd use with-open

micha01:10:07

(with-open [is (InputStream. foop)] ...)

Doug Kirk01:10:38

Any way, that's the typical idiom for closing files vs. finalizers (there's really no such thing as a destructor on the JVM)

micha01:10:48

right but lots of people don't do it

micha01:10:54

and we'll never educate them all

micha01:10:14

so in the end there will be input streams that will need to be closed by the finalization code i guess

Doug Kirk01:10:53

unless you call runFinalization explicitly (which from Javadoc indicates it'll either run in your thread or block), the finalizers really don't get run

micha01:10:18

streams could also be open in other threads, possibly, no?

Doug Kirk01:10:29

But, you could kick off a background thread to call runFinalization

Doug Kirk01:10:42

It only finalizes things that are eligible already

Doug Kirk01:10:08

And if you wanted to, you could request gc afterwards with (.gc System)

micha01:10:16

i didn't know about that lil guy

micha01:10:22

do you think it would work?

micha01:10:13

it would be so great to have boot working well in windows

Doug Kirk01:10:02

Yeah, it'll run the finalization, which should help. Certainly worth a few minutes to test to see actual impact.

micha01:10:35

awesome, thanks! @symbit 🎌

micha01:10:04

we could special case it for windows if it proves effective