Appreciating the importance of garbage collection
In the beginning, programs were small, and the static allocation of memory was decided when a program was designed. The code was not that complicated, and programmers could lay out all the memory that they were going to use during the entire program as a set of global variables. Life was good.
Then, Moore's Law happened, and computers got bigger. Customers started demanding that programs handle arbitrary-sized data instead of accepting the fixed upper limits inherent in static allocation. Programmers invented structured programming and used function calls to organize larger programs in which most memory allocation was on the stack.
A stack provides a form of dynamic memory allocation. Stacks are great because you can allocate a big chunk of memory when a function is called and deallocate memory automatically when a function returns. The lifetime of a local memory object is tied strictly to the lifetime of the function call...