On 12 Jan 2008, at 10:26 AM, Andre Nathan wrote:

On Sat, 2008-01-12 at 10:11 -0800, Jonathan Cast wrote:
A nit: the list is almost certainly getting created lazily, or you'd
get more than 300% more memory usage.  But you still get the list's
cons cells as your bookkeeping baggage, and they take up space in
exchange for greater flexibility.

But when I'm processing, say, the last directory entry, I have memory
allocated for the other 9999 entries that have already been processed,
right?

No. That would lead to a much larger difference. What you're seeing is the result of allocating a node in a linked list, not just a single directory entry. getDirectoryContents in this case certainly does not read in the entire directory, nor does it allocate space for it --- either of those would require much more than a 4x increase in the amount of memory.

I think that's where the 8M vs 2M difference comes from.

jcc

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to