Skip to content

@w01fe /locals_clearing.clj
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A bug in fine-grained locals clearing in Clojure 1.5?
(deftype FinalizeReporter [x]
Object
(finalize [this] (println "Finalizing" x))
clojure.lang.IDeref
(deref [this] x))
(defn leaker [n]
(with-open [_ (reify java.io.Closeable (close [this]))]
(let [s (map #(FinalizeReporter. %) (take 10 (iterate inc 0)))]
(when (> n -1)
(try
(->> s
(map #(do (Thread/sleep 100) (System/gc) (println @%)))
dorun))))))
ser=> *clojure-version*
{:major 1, :minor 5, :incremental 0, :qualifier nil}
user=> (leaker 10)
0
1
2
3
4
5
6
7
8
9
nil
user=> (System/gc)
Finalizing 9
Finalizing 8
Finalizing 7
Finalizing 6
Finalizing 5
Finalizing 4
Finalizing 3
Finalizing 2
Finalizing 1
Finalizing 0
user=> *clojure-version*
{:major 1, :minor 4, :incremental 0, :qualifier nil}
user=> (leaker 10)
0
Finalizing 0
1
Finalizing 1
2
Finalizing 2
3
Finalizing 3
4
Finalizing 4
5
Finalizing 5
6
Finalizing 6
7
Finalizing 7
8
Finalizing 8
9
nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.