Memory Management Flashcards

(23 cards)

1
Q

inaccessible memory

A

data that can have no use to the program but still takes up memory

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

manual memory management

A

no garbage collector, the programmer must manually allocate and deallocate memory

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

use after free

A

overwrites data used somewhere else

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

double free

A

more than one free in different places

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

invalid free

A

passing a non-malloced pointer to free

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

not checking for allocation fail

A

always check malloc != 0

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

memory leak

A

not freeing data after use

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

reading uninited memory

A

security attack vector

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

dangling pointers

A

pointers to freed memory

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

probabilistic memory safety: replacement MM

A
  • random location of objects in heap
  • heap n times larger than required
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

probabilistic memory safety: replicated mode

A

execute multiple copies concurrently, high chance correct programs output same values

different random seeds for allocators

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

garbage collection properties

A
  • intrusive, stops computation to recover memory
  • real-time, interleave computation and recovery
  • identification, reference counts or tracing+marking
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

reference counting

A

keep count of the number of pointers to an object, when reference count == 0 add object to free list

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

reference counting pros

A
  • immediate recovery
  • simple implementation
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

reference counting cons

A
  • fragmentation
  • overhead on basic operations
  • cyclic structures not recovered
  • limited size of reference count field
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

mark+sweep

A

mark all live data, sweep to collect inactive data

associate a mark with each active heap object via depth-first, in-place traversal

17
Q

mark+sweep pros

A
  • can recover cyclic garbage
  • uses all of memory
18
Q

mark+sweep cons

A
  • can be costly for large heaps
  • pauses entire program during collection
  • reclaimed memory might be fragmented
19
Q

mark+sweep+compact

A

uses mark+sweep and then makes all live data contiguous

copies data breadth first, uses forwarding pointers

20
Q

forwarding pointer

A

when data is moved a forwarding pointer is placed at the old location which stores the datas new position

21
Q

2-space copy

A

memory is in two equal regions, FROM and TO

data is allocated in FROM, when FROM fills active data is copied to TO and they are swapped

22
Q

2-space copy pros

A
  • recovers cycles
  • compacts live data
  • only scans live data
23
Q

2-space copy cons

A

wastes memory