A memory leak occurs when memory that is no longer needed is not released, leading to a situation where the available memory gradually decreases over time. This typically happens in the heap memory, where dynamically allocated memory is not freed after use.
Among the options given:
- A heap gets too large. - This is a likely scenario for a memory leak, as unused allocated memory accumulates and is not released.
- A heap gets too small. - This is not a correct statement about memory leaks.
- A stack gets too large. - This can lead to a stack overflow but is not a memory leak.
- A stack gets too small. - This is also not related to memory leaks.
The most appropriate answer is a heap gets too large.