Memory & Performance Flashcards

(15 cards)

1
Q

stack allocation

A

Memory allocated automatically for local variables;
very fast, lifetime tied to scope.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

heap allocation

A

Memory allocated dynamically (new/malloc);
slower, requires manual/free or smart pointers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

memory pool

A

Pre-allocated block of memory for fast allocation/deallocation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

memory leak

A

Memory allocated but never freed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Dangling Pointer

A

Pointer to freed memory;
unsafe, causes undefined behavior.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

RAII
(Resource Acquisition Is Initialization)

A

Manage resources via object lifetime;
ensures cleanup.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Copy vs Move

A

Avoid unnecessary deep copies; use move semantics to transfer ownership efficiently.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Smart Pointers
(unique_ptr, shared_ptr, weak_ptr)

A

manage heap memory safely and prevent leaks.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Cache Locality

A

Accessing contiguous memory improves CPU cache usage;
vector > deque > list.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Spatial Locality

A

Accessing memory addresses near each other; improves cache hits

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Temporal Locality

A

Re-accessing recently used memory; improves cache reuse

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Contiguous Storage

A

Using structures like vector for sequential memory;
improves cache efficiency.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Memory Contention

A

Multiple threads accessing shared memory;
can cause stalls.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Time Complexity Awareness

A

O(1), O(log n), O(n) costs for data structures and operations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Hot / Cold Data Separation

A

Separate frequently accessed vs rarely accessed data to improve cache hits.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly