Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why would anyone use best fit memory allocation?

I'm reading Modern Operating Systems by Andrew Tanenbaum, and he writes that best fit is a widely used memory allocation algorithm. He also writes that it's slower than first fit/next fit since it have to search the entire list of allocated memory. And that it tends to waste more memory since it leaves behind a lot of small useless gaps in memory.

Why is it then widely used? Is it some obvious advantage i have overlooked?

like image 307
bobbaluba Avatar asked Dec 06 '11 14:12

bobbaluba


People also ask

Why might we use best fit over first fit for block selection?

Large blocks can fit unknown future needs better than small blocks, so a best-fit algorithm tries to use the smallest blocks first. First-fit and next-fit algorithms (that can also cut up blocks) may end up using pieces of the larger block first, which increases the risk that a large malloc() will fail.

What is best fit in memory allocation?

Best Fit. The best fit deals with allocating the smallest free partition which meets the requirement of the requesting process. This algorithm first searches the entire list of free partitions and considers the smallest hole that is adequate. It then tries to find a hole which is close to actual process size needed.

What are the benefits and disadvantages of the first fit best fit and the worst fit memory allocation technique?

Memory utilization is much better than first fit as it searches the smallest free partition first available. It is slower and may even tend to fill up memory with tiny useless holes. In worst fit approach is to locate largest available free portion so that the portion left will be big enough to be useful.

What is the purpose of memory allocation?

Memory allocation is a process by which computer programs and services are assigned with physical or virtual memory space. Memory allocation is the process of reserving a partial or complete portion of computer memory for the execution of programs and processes.


1 Answers

First, it's is not that widely used (like all sequential fits), except, perhaps, in homeworks ;). In my opinion, the widely used strategy is segregated fits (which can very closely approximate best fit).

Second, best fit strategy can be implemented by using a tree of free lists of various sizes

Third, it's considered one of the best policies with regard to memory fragmentation

See

Dynamic Storage Allocation: A Survey and Critical Review

The Memory Fragmentation Problem: Solved?

for information about memory management, not Tannenbaum.

like image 127
chill Avatar answered Sep 19 '22 02:09

chill