A memory leak is a scenario that occurs when objects are no longer being used by the application. I think in the case of a recursive call, the objects are required at a later point. So I would not consider a stack overflow error a memory leak.
“Memory leak”, in brief, refers to the scenario that memory is allocated but not released even if it is no longer needed.
A stack overflow itself is NOT causing any unneeded memory to fail to be released. There is no reason that you can treat a stack overflow as a “memory leak”.
Read more here: Source link