Hi Robert,
I tracked down the source of the StackOverflowError in my code. It
boils down to the following similar (to your example) code snippet.
Although, on my machine, this example gives the stack overflow, rather
than the OOM error.
(def acoll (ref []))
(doseq [i (range 1 3000)]
(println
Hi Kyle!
I encountered the same problem:
(defn stack-fail
returns an empty lazy seq
[l i]
(if ( i 0)
(recur (remove #{1} (concat l '(1))) (dec i))
l))
(def foo (stack-fail () 1000))
foo
; Evaluation aborted.
if you call a non-lazy function (e.g. doall) on the collection from
Hi Robert,
Thanks for your reply! Very interesting. I see what you're saying.
But, your code results in a OutOfMemoryError, rather than a
StackOverflow.
At least, that's what I see on my machine. Are you seeing the same?
Is there some way that this same concept could lead to a
StackOverflow?
Is it possible that the Clojure core seq function can cause a stack
overflow (since it calls itself)?
Or is there some other manner in which misuse of a lazy seq could
cause this? In the stack trace below, I'm seeing repeated calls to
seq in clojure core, until the stack is blown.
Thanks,
Kyle