Stack Memory
Stack memory is a type of computer memory used for temporary storage of data. It operates in a last-in, first-out (LIFO) manner, meaning the most recently added data is the first to be removed. This memory is primarily used for managing function calls, local variables, and control flow in programming languages like C and Java.
When a function is called, a new block of memory, called a stack frame, is created on the stack. This frame holds the function's parameters, local variables, and return address. Once the function completes, its stack frame is removed, freeing up that memory for future use.