
On Thu, May 03, 2007 at 05:40:24PM +0100, Adrian Hey wrote:
Duncan Coutts wrote:
On Thu, 2007-05-03 at 16:24 +0100, Adrian Hey wrote:
Hello Folks,
Just wondering about this. Please understand I'm not asking why programs use a lot of stack sometimes, but specifically why is using a lot of stack (vs. using a lot of heap) generally regarded as "bad". Or at least it seems that way given that ghc run time makes distinction between the two and sets separate limits for them (default max stack size being relatively small whereas default max heap size in unlimited). So programs can fail with a stack overflow despite having bucket loads of heap available?
Perhaps it's there to help people who write simple non-terminating recursion. They'll get an error message fairly soon rather than using all memory on the machine and invoking the wrath of the OOM killer.
Hmm, I still don't see why a "stack leak" should be treated differently from "heap leak". They'll both kill your program in the end.
I believe it is because a stack cannot be garbage collected, and must be traversed as roots for every garbage collection. I don't think there are any issues with a huge stack per se, but it does not play nice with garbage collection so may hurt your performance and memory usage in unforeseen ways. John -- John Meacham - ⑆repetae.net⑆john⑈