Why do we have stack overflows?

Brian Hulley brianh at metamilk.com
Mon May 7 06:07:14 EDT 2007


Brandon Michael Moore wrote:
> On Thu, May 03, 2007 at 04:59:58PM -0700, John Meacham wrote:
>   
>> 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.
>>     
>
> Isn't it just the top of the stack that has to be treadted as a root?
>   
No, because the functions below the top are still active and would 
usually be referencing other heap locations not visible to the top function.

On another note, why use stacks in the first place? Couldn't all 
activation  records just be heap allocated?

Regards, Brian.


More information about the Glasgow-haskell-users mailing list