basic dynamic memory allocation Flashcards

1
Q

which area of memory does malloc manage

A

heap

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

explicit vs implicit allocator

A

explicit: you do it. malloc and free

implicit: im nice :) garbage collection

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

throughput

A

number of completed requests per unit of time

5000 mallocs and 5000 frees in 10 seconds = 1k operations/sec & mentally insane

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

peak memory utilization

A

basically the most payload you’ve had thus far. you just care abt the peak. so if you free’d, no nah you didnt.

max payload over lifetime / heap size

so get your mallocs in

fragmentation ruins this :(

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

internal fragmentation

A

payload / block size

caused by the need for headers & padding , or design implementation

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

external fragmentation

A

holes left in the heap from a mix of mallocs and free

sometimes you have enough memory for a malloc, but they’re not together

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

methods of tracking free blocks

A
  1. implicit list - all blocks in one list (linear allocation time)
  2. explicit list - all free blocks in one list (linear with respect to free blocks)
  3. segregated free list (hw3) - different free list for different sizes (approximate a best fit)
  4. free blocks sorted by size perfectly, such as with a red-black tree
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

First fit policy

A

start from beginning of list, iterate until ones found

causes splinters

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

Next fit

A

starting from where you last were, search until ones found

worse fragmentation

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

best fit policy

A

do an exhaustive search of list and find the best one

slower, but best memory usage

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

splitting

A

cutting a free block into two blocks so you only use whats absolutely needed

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

coalescing

A

when freeing a block, merge it with any potential neighboring free blocks to avoid external fragmentation.

in order to have bidirectional coalescing you need a header and a footer

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

immediate coalescing

A

coalesce when you free.

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

deferred coalescing

A

coalesce when you malloc and search a list.

another option is to coalesce when your external fragmentation gets too high

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

LIFO insertion policy

A

put free block at beginning of list

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

address ordered insertion policy

A

insert free block so the list is in order by address

“studies suggest fragmentation is lower”