On Dec 7, 1:52 am, Chouser <[EMAIL PROTECTED]> wrote:
> On Sun, Dec 7, 2008 at 1:16 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> > I'm also running into, what I believe to be, the same problem.  Every
> > time I run the following code I get "java.lang.OutOfMemoryError: Java
> > heap space".
>
> > (use 'clojure.contrib.duck-streams)
> > (count (line-seq (reader "big.csv")))
>
> > If I change "count" to "dorun" then it will return without problem.
>
> I think I can reproduce this one like so:
>
> user=> (count (take 15000 (iterate #(str % "more") "some")))
> java.lang.OutOfMemoryError: Java heap space (NO_SOURCE_FILE:0)
>
> As with yours, I can replace 'count' with 'dorun' and it works fine.
> I can also use 'last':
>
> user=> (.length (last (take 15000 (iterate #(str % "more") "some")))))
> 60000
>
> I think the problem in this case is 'count', which for all
> IPersistentCollections (including lazy sequences) calls the 'count'
> method of the instance.  ASeq's count method is a tight for() loop,
> but since it's an instance method it must retain a 'this' reference to
> the head of the seq.
>
> Fixing this is hard becasue RT.count() is holding onto the head as
> well.  I've attached a patch that fixes the problem, but it's pretty
> ugly, perhaps only useful to demonstrate that this is the problem.
>
> --Chouser
>
>  count-lazy.patch
> < 1KViewDownload

I started a new thread since these problems may be independent of each
other.  I don't want to get this one off track.

http://groups.google.com/group/clojure/browse_thread/thread/41bc83dbe3cccc74

--~--~---------~--~----~------------~-------~--~----~
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
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to