Skip to content Skip to sidebar Skip to footer

Does A Recursive Settimeout Cause A Stack Info Memory Leak?

I have the following scenario: Although I read that clearing the timeout handle will release the memory for closures and the handler itself, I am still curious if there might be a

Solution 1:

No. When func finishes execution, the stack unwinds.

If func would be recursive, the stack would look like:

   [init] -> func -> func -> func -> func -> func -> .... 

In your case however it is:

  [init] -> func -> setTimeout
       <----     <----

  [timer] -> func -> setTimeout
      <----      <----

  [timer] -> func -> setTimeout
      <----      <----

  ...

Post a Comment for "Does A Recursive Settimeout Cause A Stack Info Memory Leak?"