Dynamic Memory Flashcards

1
Q

Throughput vs good memory utilization

A

good memory utilization requre more operations to decide where to allocate memory so this increases throughput.

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

Memory utilisation

A

total bytes allocated / total bytes of heap or page

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

Internal fragmentation

A

= payload / block size
payload is the bytes occupied
the heap is usually divided into blocks of a certain byte. exp. 16 bytes, malloc(10) like have frag = 10/16

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

External fragmentation

A

when the total aggregated available heap memory is enough but there’s no free block large enough

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

Heap

A

a contiguous block of memory for dynamically allocated memory in a program. Usually invoked by malloc

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

Explicit memory management

A

explicitly allocating and freeing memory (exp. malloc & free)

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

Implicit memory management

A

an application allocates memory but implicitly deallocates. (exp. garbage collector that cleans up unused memory)

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

Implicit free list

A

contains a list where each element has a header for every block of memory. If header is 8 bits, the first bit is to determine it is used/unused 1/0.

when memory is allocated to a free block, the block will be split into two, occupied and unoccupied.

when memory is freed, the list should join adjacent free blocks together.

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

Explicit free list

A

doubly linked list of pointers pointing to the starting location of free blocks in the heap.

when memory is allocated, find the best fit block by traversing the list.

when memory is freed, the list will be inserted either in LIFO or in address-order. Free block with lowest address is at the start of the list.

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

Segregated free lists

A

multiple lists where lists of the same sizes are grouped together. Each list has a size class.

when memory is allocated, the first block in the class size list requested is used. If list is empty, the next size up list is used. If no lists can fit, then sbrk() is called to request OS to increase size of heap.

when memory is freed, the block is added to the appropriate free list.

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

Bidirectional coalescing

A

Can be applied to any list. Add boundary tags where the size of the block is written at the start and end of the block (header & footer). This allows traversing the list backwards from any node. Joining/coalescing takes constant time with boundary tags O(no. of nodes to join).

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

Cons of implicit free list

A

linear time operation based on the number of blocks in a heap because it requires traversing the entire list to find free blocks that fit.

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

Pros of explicit free list

A

malloc operation requires linear time based on the no. of free blocks instead of total blocks in the heap.

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

Explicit free list LIFO vs Address-order

A

LIFO causes more fragmentation than address-order but it takes contsant time O(1) for insertion. Address-order is not constant time, requires searching the list for insertion.

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

Pros of Segregated free lists

A

high throughput and better memory utilizaiton. Search the first fit list is faster then finding the best fit block in an entire heap most of the time.

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

Binary buddy allocator

A

A binary tree of free blocks where each node has sizes increasing by powers of 2 (exp. 1,2,4,8,16..).

When allocating memory, the nearest 2 to the power size node that fits is used. If a node size is larger than requested, it is split into half (two equal sized buddy blocks) and the block is allocated. The block allocated will be removed from the binary tree