Quote:
in you example you have main call func. func reaches it end and the memory allocated for count is set free, main however never reaches an end till the entire program is done. This results in J being kept whereas count is not because func is ended but main is not.
Sorry thats wrong. count is global, it will not be destroyed until after main exits. j on the other hand is local to the loop and cannot be accessed outside the loop being as it has been destroyed when you exited the loop. Remember your scoping rules.