- Unordered free space allocated in memory.
- A region in memory that keeps track of function calls and operates in “first in last out” mode. Functions tracked in the call stack, point to the memory heap to get the values they need to complete their tasks.
Simple variables are stored on the call stack itself, but more complex data structures like objects and functions are stored on the memory heap.
Memory leaks happen when a piece of memory that is no longer needed is not cleaned up by the garbage collector.
Examples of memory leaks:
- Declaring global variables
- Adding, but not removing event listeners
setIntervalwithout clearing it