A memory allocation ADT Flashcards

1
Q

for memory allocation ADT how is object memory maintianed in a buffer of generic memory

A

the buffer is declared as an array of bytes(unsigned char)

we allocate two buffers, one that is currently in use, the other for running our memory recovery (compaction or defragmentation) operation

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

What is used to keep track of objects that have been allocated? How does it work and how is a new item added?

Draw it.

A

A linkedlist:

  • each node is a struct that contains all the required information about the allocated block
  • we maintain a free memory index that points to the start of the unallocated portion of the array
  • To request memory for an object, we reserve the next block of free memory from the buffer, and add a new item to the end of the linked list
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What happens when a reference count for an object reaches 0? What happens to it’s memory

A

We simply remove it’s entry from the linked list.

Nothing happens to memory until the garbage collector actually runs

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

What causes memory fragmentation? Draw it.

A

As objects are created and then marked as garbage, the memory will become fragmented.

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

When is the garbage collect algorithm run?

A

when we no longer have enough free memory at the end of the array to satisfy a memory request.

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

How does this garbage collection work for our HW4 ADT?

Draw it.

A
  • copying the physical memory and update their entries in the linked list
  • also maintain a pointer to the buffer currently being used.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly