I have the function:
((lambda (x) (x x))
(lambda (x) (x x)))
and it produces an infinite loop. My question is about the memory map. We know that the stack would overflow, because I open a new frame each call. But what will be on the heap? As I understood it, on every call a new closure would be created on the heap, but I’m not sure about this.
The stack will not overflow, because Scheme mandates tail call optimization (or something equivalent to it). No new call frames are created. Also, only constant heap allocation is required to execute this function; the interpreter needs only evaluate two
lambdaexpressions, producing two closures.If you want to fill up memory, do something like