To be explicit, the doall needs to be before the call to recur (that is, it affects the map). Is that right?
On Oct 5, 1:31 am, Meikel Brandmeyer <m...@kotka.de> wrote: > Hi, > > On Oct 5, 9:50 am, Volkan YAZICI <volkan.yaz...@gmail.com> wrote: > > > > (defn leak [] > > > (loop [v [0 0]] > > > (recur (map + v [1 1])))) > > > > Adding a doall call fixed the leak. > > > Could you please provide a more concrete (if possible working) example? > > I'm trying to figure out the actual reason of the problem, and there are > > still some missing parts in the maze. > > map is lazy and hence has to store a reference to the original > sequence, which is released when realising the map sequence. The loop > builds up a stack of maps which each keeps references in their guts. > So the memory builds up and up and up and *BOOM*. The doall realises > the sequence and hence the reference to the input sequence can be > dropped. It gets GC'd and everything is fine. > > Sincerely > Meikel --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---