I was working with a large data set earlier today, and I had written a
loop/recur where I was passing in a huge seq to the first iteration,
and I was surprised when I ran out of heap space, because I was very
careful not to hold on to the head of the seq, and I though that loop
ended up rebinding all of its params (and didn't hold on to the
initial values).

When I run the following code:

(defn loop-test []
  (loop [[head & tail] (repeat 1)]
    (recur tail)))

It will blow the heap on a 1.5 JDK, but I can't seem to make that
happen under a 1.6 JDK. I ran into a previous issue that was similar
(with respect to only manifesting on an older JDK), and it turned out
to be a bug in clojure (fixed in svn 1153).

I noticed that this doesn't occur if I don't use destructuring:

(defn loop-test2 []
  (loop [s (repeat 1)]
    (recur (rest s))))

This version seems to run forever on either JDK, using a constant
amount of heap space.

Is this behavior due to some artifact of destructuring I'm not aware
of (or something else I'm missing), or is there a bug? If it sounds
like a bug, can anyone else reproduce?

Thanks!
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to