• Home
  • Textbooks
  • Data Structures and Algorithms in C++
  • MEMORY MANAGEMENT

Data Structures and Algorithms in C++

Adam Drozdek

Chapter 12

MEMORY MANAGEMENT - all with Video Answers

Educators


Chapter Questions

Problem 1

What happens to the first-fit method if it is applied to a list ordered by block sizes?

Check back soon!

Problem 2

How does the effort leading to coalescing blocks in sequential-fit methods depend on the order of blocks on the list? How can possible problems caused by these orders be solved?

Check back soon!

Problem 3

The optimal-fit method determines which block to allocate after examining a sample of blocks to find the closest match to the request and then finds the first block exceeding this match (Campbell 1971). What does the efficiency of this method depend on? How does this algorithm compare to the efficiency of other sequential-fit methods?
FIGURE 12.17 FIG CANT COPY
(a) Left degenerate and (b) right degenerate list structures.

Check back soon!

Problem 4

In what circumstances can the size-list in the adaptive exact-fit method be empty (except at the beginning)? What is its maximal size and when can it be this size?

Check back soon!
View

Problem 5

Why in the buddy system are doubly linked, not singly linked, lists of blocks used?

Emily Himsel
Emily Himsel
Numerade Educator

Problem 6

Give an algorithm for returning blocks to the memory pool using the Fibonacci buddy system.

Check back soon!

Problem 7

Apply markingWithstack () to the lefi degenerate and right degenerate list structures in Figure 12.17. How many calls to pop () and push () are executed for each case? Are all of them necessary? How would you optimize the code to avoid unnecessary operations?

Check back soon!

Problem 8

In a reference count method of garbage collection, each cell chas a counter field whose value indicates how many other cells refer (point) to it. The counter is incremented every time another cell refers to $c$ and decremented if a reference is deleted. The garbage collector uses this counter when sweeping the heap: If a cell's count is zero, the cell can be reclaimed since it is not pointed to by any other cell. Discuss the advantages and disadvantages of this garbage collection method.

Check back soon!
01:52

Problem 9

In Baker's algorithm, the scanning performed by the collector should be finished before bottom reaches top in tospace to flip spaces. What should the value of $k$ be to ensure this? Assume that $n$ is the maximum number of cells required by a program, and $2 m$ is the number of cells in fromspace and in tospace. What is the impact of doubling the value of $k$ when it is an integer and when it is a fraction (for example, if it is .5, then one copy is made per two requests)?

Manik Pulyani
Manik Pulyani
Numerade Educator

Problem 10

In a modification of Baker's algorithm which requires updating heap pages in the case when the mutator's access is trapped (Ellis, $\mathrm{Li}$, and Appel 1988), there is a problem with objects that may cross the page boundary. Suggest a solution to this problem.

Check back soon!