Hello!
This little snippet demonstrates the problem:
(doseq [outer-seq (list (range)) inner-seq outer-seq])
That's it. It is not just eats my processor, but also eats all available memory. Practically it can affect (and it is) at consuming of complex lazy structures like huge XML-documents.
I think this is at least non trivial behaviour.
It can be fixed by this small patch. We can get next element before current iteration, not after, so outer loop will not hold reference to the head of inner-seq.
This patch doesn't solve all problems, for example this code:
(doseq [outer-seq [(range)] inner-seq outer-seq])
leaks. Because chunked-seqs (vector in this case) holds current element by design.