
Hi Thomas, thanks for the reply!
Thomas DuBuisson
Josh,
In general you'll find the haskell-cafe (haskell-cafe <at> haskell.org) to be a more lively place for this type of discussion
Good to know, I just wasn't sure if it was appropriate for GHC-specific questions.
but since we're here I might as well mention that memory use of a Haskell function is one of the hardest things to gain an understanding about.
Hmm, that's unfortunate. :(
main = print (show (sum [x | x <- [3..999], x `mod` 3 == 0 || x `mod` 5 == 0])) I want to know if the list was ever actually constructed in memory.
For such a simple program I suggest you test with lists of various lengths:
Cool, thanks for the example.
94,604 bytes allocated in the heap
Is there any way I could find out what these 94kb of RAM were allocated for? This seems high -- my entire program's working set is <6kb. That's if you construct all my lists in full, including both the [3..999] list (which has 997 elements) and the list comprehension list (which has 466). This assumes 32-bit integers. Allow for some memory to format the string, and you still aren't within an order of magnitude of 94kb. I guess I'm holding Haskell to the standard of a compiled language rather than interpreted one, and assuming it doesn't need to allocate heap space for the code. Any idea how I could dig into this?
The C it produced with '-fvia-C -C' was totally unreadable
Deprecating the via-C compilation path has been discussed - hopefully no one ever suggested it as a useful path for human inspection.
I do still wonder if there isn't an intermediate form that *is* suitable for human inspection. Thanks, Josh