The same goes for delay (where the lambda reference is nullified), which 
leaves future-call, and even there :once is not really necessary.

A cursory benchmark indicated that lazy-seq does not, in fact, leak memory 
on long sequences, even without the :once flag. Am I missing anything?

BTW, the :once mechanism isn't (if I'm not mistaken) thread-safe. That's 
why LazySeq and Delay had to use synchronized blocks even when they relied 
on :once (again, if I'm correct in the assessment that they no longer do).



On Tuesday, February 18, 2014 7:39:06 PM UTC+2, pron wrote:
>
> lazy-seq marks it's supplied lambdata with ^{:once true} to prevent the 
> memory leak described at the bottom of this page <http://clojure.org/lazy>
> .
> However, while going over the code for clojure.lang.LazySeq, I noticed 
> that ever since this commit by 
> Rich<https://github.com/clojure/clojure/commit/9253928ba2330b9929eb26577ba20047fb24c5de#diff-829faa850c65e040e132cd9243bf7ac2R42>,
>  
> LazySeq doesn't extend AFn, but rather contains a reference to the lambda, 
> fn, which it nullifies immediately after the first use, supposedly 
> preventing any leaks caused by closed locals.
> So my question is, is ^{:once true} still necessary for lazy-seqs, or does 
> this (pretty old) change to LazySeq make it redundant?
>
> Ron
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to