Why do programming languages need garbage collection?
arpit.substack.com
Our programs need memory, typically in the form of variables and objects, to do their job. The objects are either allocated on Stack or Heap. Stack allocated objects A locally declared variable "int a = 10;" is allocated on the stack i.e. the stack frame of the function call and hence when the function returns the stack frame is popped, making the variable non-existent. Hence variables allocated on Stack do not need to be freed explicitly.
Why do programming languages need garbage collection?
Why do programming languages need garbage…
Why do programming languages need garbage collection?
Our programs need memory, typically in the form of variables and objects, to do their job. The objects are either allocated on Stack or Heap. Stack allocated objects A locally declared variable "int a = 10;" is allocated on the stack i.e. the stack frame of the function call and hence when the function returns the stack frame is popped, making the variable non-existent. Hence variables allocated on Stack do not need to be freed explicitly.