On Sun, Oct 28, 2012 at 9:38 AM, Christian Sperandio
<christian.speran...@gmail.com> wrote:
>
> I've got a question about lazy-sequence and file reading.
> Is line-seq good to process lines from huge file?
> Let take this case, I want to process each line from a file with one or more
> functions. All lines must be processed. Line-seq return a lazy sequence, it
> means all already read lines stay in memory, doesn't it?
> So, if the processed file's size is many gigabytes, my heap size will
> explode, right?  Or did I miss something?
>

You missed something. All lines only stay in memory if you hold on to
a reference to the beginning of the sequence. ("Holding on to the
head".) Generally, doing that is a bug. The whole point on lazy
sequences is that you don't need to hold the whole sequence in memory,
when you're processing it one item at a time.

// Ben

-- 
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