Re: Head retention example

2013-04-23 Thread xumingmingv
Thanks Colin! 在 2013-4-24,上午9:23,Colin Fleming 写道: > I'm pretty sure the implementation of locals clearing is all in > Compiler.java, in the LocalsBinding class. See canBeCleared in that class. > > > On 23 April 2013 23:37, xumingmingv wrote: > Michal, do you know any resources/links that int

Re: Head retention example

2013-04-23 Thread Colin Fleming
I'm pretty sure the implementation of locals clearing is all in Compiler.java, in the LocalsBinding class. See canBeCleared in that class. On 23 April 2013 23:37, xumingmingv wrote: > Michal, do you know any resources/links that introduce the internals of > local-clearing? or The Clojure source

Re: Head retention example

2013-04-23 Thread xumingmingv
Michal, do you know any resources/links that introduce the internals of local-clearing? or The Clojure source files which implemented this technique? 在 2013-4-23,下午3:55,xumingmingv 写道: > Thanks a lot Michal! > > 在 2013-4-21,上午6:51,Michał Marczyk 写道: > >> On 20 April 2013 23:41, Tonino Jankov

Re: Head retention example

2013-04-23 Thread xumingmingv
Thanks a lot Michal! 在 2013-4-21,上午6:51,Michał Marczyk 写道: > On 20 April 2013 23:41, Tonino Jankov wrote: >> I mean, I think that in both cases the original sequence at one point in >> time must be, entirely realized, in memory. > > Well no, it doesn't. > > The original sequence is lazy and c

Re: Head retention example

2013-04-22 Thread tyaakow
Thank you for the exhaustive explanation, Michal. -- -- 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 po

Re: Head retention example

2013-04-20 Thread Michał Marczyk
PS. Of course the other key detail is that lazy sequences are realized little by little (1 element at a time or up to 32, depending on whether they're chunked or not; the original sequence here is chunked, so the arrays underlying the chunks will be filled 32 elements at a time, but then the iterat

Re: Head retention example

2013-04-20 Thread Michał Marczyk
On 20 April 2013 23:41, Tonino Jankov wrote: > I mean, I think that in both cases the original sequence at one point in > time must be, entirely realized, in memory. Well no, it doesn't. The original sequence is lazy and chunked, so it looks like a chain of links holding 32 elements each. It so

Re: Head retention example

2013-04-20 Thread Tonino Jankov
I think what Michal is saying is that in "good" case, the original sequence is cleared instantly upon being realized and in OOME case it hangs around, so the issue is not the quantity of memory occupied by it, but also the length of time interval it occupies the memory (in OOME case it stays in mem

Re: Head retention example

2013-04-20 Thread Tonino Jankov
I mean, I think that *in both cases* the original sequence *at one point in time* must be, entirely realized, in memory. And if there is no doubling of it in critical case, what is critical? If in (count t) (count d) - non.problematic- case original sequence also, *at one poin*t, is, actually, in

Re: Head retention example

2013-04-20 Thread Tonino Jankov
Marko, you say "There is no doubling: *t* and *d* share the same underlying lazy sequence and will refer to the same objects. The trouble is only that you force the evaluation of *(count d)* while *(count t)* still waits to be evaluated, so *t* must definitely stay bound to the head of the shared s

Re: Head retention example

2013-04-17 Thread Michał Marczyk
Note that the problem is not that t needs to hang around; it's that t holds a lazy sequence which hangs around in unrealized state. That lazy sequence internally holds a thunk -- a nullary function -- capable of producing the actual sequence elements on request. It is this thunk that holds a refere

Re: Head retention example

2013-04-17 Thread Marko Topolnik
On Monday, April 15, 2013 1:50:37 AM UTC+2, tyaakow wrote: > Thank you for your response, Marko. > I want to clarify one more thing: > > (let [[t d] (split-with #(< % 12) (range 1e8))] > [(count d) (count t)]) > > > does this mean that while (count d) is realizing (range 1e8) seq, it > become

Re: Head retention example

2013-04-17 Thread gerardc
Great Q&A on this, thanks Marko! On Sunday, 14 April 2013 19:13:51 UTC+1, Marko Topolnik wrote: > > On Sunday, April 14, 2013 2:58:55 AM UTC+2, tyaakow wrote: > >> I'm reading Clojure Programming book by O'Reilly.. >> >> I came over an example of head retention. First example retains reference >>

Re: Head retention example

2013-04-14 Thread tyaakow
Thank you for your response, Marko. I want to clarify one more thing: (let [[t d] (split-with #(< % 12) (range 1e8))] [(count d) (count t)]) does this mean that while (count d) is realizing (range 1e8) seq, it becomes (also) realized within t, therefore it doubles (range 1e8) in memory cau

Re: Head retention example

2013-04-14 Thread Marko Topolnik
On Sunday, April 14, 2013 2:58:55 AM UTC+2, tyaakow wrote: > I'm reading Clojure Programming book by O'Reilly.. > > I came over an example of head retention. First example retains reference > to d (I presume), so it doesnt get garbage collected: > > (let [[t d] (split-with #(< % 12) (range 1e8))]

Head retention example

2013-04-13 Thread tyaakow
I'm reading Clojure Programming book by O'Reilly.. I came over an example of head retention. First example retains reference to d (I presume), so it doesnt get garbage collected: (let [[t d] (split-with #(< % 12) (range 1e8))] [(count d) (count t)]);= # While second example doesnt retain