Thursday, 12 September 2013

JavaScript - Garbage collection after function calls

JavaScript - Garbage collection after function calls

I had some reads about garbage collection in JavaScript, according to
them, local variables of functions are collected after the function
returned (except for the cyclical references that need breaking circles
for the GC to work).
What I'm trying to understand is, what does "function returned" in this
context mean?
Does it mean:
The function has to return values.
or simply:
The function call has ended.
Common sense (according to me at least) suggests 2), but in the case I'm
wrong:
What about functions that don't return values?
Should I add an empty return; to the functions that don't return anything
to make the garbage collector do its job?

No comments:

Post a Comment