javascript - recursive calls to ajax cause memory leak? -


does following code logic cause original call's stack frame contain memory each subsequent call (causing excessive memory usage)?

function foo (arg) {     bar(arg); }  function bar (arg) {   $.ajax({      success: function (data) {          if (data['result'] == 'continue') {             bar(data['nextarg']);          } else if (data['result'] == 'done') {             alert('done!');          }      }   }); } 

your code not recursive. $.ajax asynchronous, stack pointer isn't waiting bar return.

instead, $.ajax fires asynchronous process, continues until hits either explicit or implicit return. in case, there implicit return @ end of bar.

your function consumes no more memory should.

function bar (arg) {   // calls $.ajax, async, fires "whenever"   $.ajax({     // when ajax complete/successful, function called       success: function (data) {          if (data['result'] == 'continue') {             bar(data['nextarg']);          } else if (data['result'] == 'done') {             alert('done!');          }      }   })   // exits after } 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -