Memory Management & Performance Optimization Flashcards
6 cards from real CPP practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 6 Memory Management & Performance Optimization flashcards as text
What is a memory leak in software applications?
Answer: Allocated memory that is never freed, causing the program to consume increasing amounts of RAM
A memory leak occurs when a program allocates heap memory but never releases it, eventually exhausting available memory.
What is garbage collection in a managed runtime environment?
Answer: Automatic identification and freeing of memory no longer referenced by the application
Garbage collection automates memory reclamation by detecting objects with no live references and freeing their memory.
What is the difference between stack and heap memory?
Answer: Stack memory is automatically managed and stores local variables; heap memory is dynamically allocated and manually managed
The stack holds local variables with automatic allocation/deallocation per function call, while the heap holds dynamically allocated objects.
What does 'Big O notation' measure in algorithm performance?
Answer: How an algorithm's runtime or space requirements grow relative to input size
Big O notation describes the upper bound of an algorithm's time or space complexity as a function of input size.
What is CPU cache locality and why does it matter for performance?
Answer: Accessing data that is physically close in memory, improving cache hit rates and reducing access time
Cache locality means accessing contiguous or nearby memory addresses so data is likely already in the fast CPU cache, reducing costly RAM fetches.
What is object pooling as a performance optimization technique?
Answer: Reusing a set of pre-allocated objects instead of repeatedly creating and destroying them
Object pooling reduces garbage collection pressure and allocation overhead by recycling expensive-to-create objects.