It isn't because it runs forever, it's because each function calls reserves stack space (and gives it back when it returns), calling a very large number of nested functions (never returning) exhausts the stack.
Yep, every function has a stack, with a fixed initial size. When functions were called inifinately, the remaining memory space would be exhausted very soon. Then a stack overflow occurs.
Functions consume stack space (not heap space) for their variables for as long as they are running, in particular this function is storing n on the stack. Since it's a recursive function, there are more and more copies of n being created at the same time.
However, if you compile this in release mode rather than in debug mode, tail call optimization kicks in and this turns into an infinite loop that does not consume the stack.
Mostly, with a minor nitpick:
Not heap space, stack space located in a different segment.
In modern operating systems, memory is usually stored in segments, such as Stack Segment, Data Segment, BSS, Data Segment, Code Segment... Each has its own space with a different length.
So the infinite loop function actually runs out of the stack memory segment, then a stack overflow was given. But if it is not the stack space that is depleted, the error will be varied.