Fork me on GitHub
#clojure-dev
<
2017-04-08
>
mikekap03:04:19

hey folks, I found an interesting peculiarity with locals clearing (run with -Xmx5m):

(defn test [x]
  (if true
    (do
      (try (doseq [_ x] _) (finally))
      1)
    0))

(test (take 1000000 (range)))
will OOM

mikekap03:04:41

BUT, this won’t:

(defn test [x]
  (do
    (try (doseq [_ x] _) (finally))
    1))

(test (take 1000000 (range)))

bronsa08:04:25

interesting, i'll take a look

bronsa09:04:40

i have a vague idea of why this is happening

bronsa09:04:39

(fn foo [x]
  (if true
    (^:once fn* []
     ;; x is not cleared here
     x)))