Common memory allocation algorithms and their advantages and disadvantages

Source: Internet
Author: User

Common memory allocation algorithms and their advantages and disadvantages

Common memory allocation algorithms and their advantages and disadvantages are as follows:
(1) first algorithm adaptation. When you use this algorithm to allocate memory, you can start from the beginning of the idle partition chain until you find an idle partition that can meet the size requirements. Then, based on the job size, a piece of memory is allocated from the partition to the requester, and the remaining idle partitions are still in the idle partition chain.

This algorithm tends to use the idle partitions in the middle and low addresses in the memory, which are rarely used in the idle partitions in the high addresses, thus retaining the large idle partitions in the high addresses. It is obvious that a large number of tasks will be allocated in the future.
The storage space creates conditions. The disadvantage is that the low-address part is constantly divided, leaving many idle areas that are difficult to use and small, and each search starts from the low-address part, which will undoubtedly increase the search overhead.

(2) The first adaptive algorithm for loop. This algorithm evolved from the first adaptive algorithm. When allocating memory space for a process, it does not start searching from the beginning of the chain every time, but starts searching from the idle partition found last time
Find a free partition that can meet the requirements, and draw a partition from it to the job. This algorithm can make the memory partitions in the idle state more evenly distributed, but there will be a lack of large idle partitions.
(3) optimal adaptive algorithm. This algorithm always allocates the smallest idle partitions that meet the requirements to the job.

To accelerate search, this algorithm requires that all idle zones be sorted by their sizes to form a blank chain in ascending order. In this way, the first idle zone that meets the requirements will be the best. In isolation,
This algorithm seems to be optimal, but in fact it is not necessarily. Because the remaining space after each allocation must be the smallest, there will be many small idle areas that are difficult to use in the memory. At the same time, it must be re-ordered after each allocation,
This also brings about some overhead.
(4) The worst adaptive algorithm. In the worst adaptive algorithm, the idle zone chain is formed in the descending order of size, and is directly allocated from the first idle partition of the idle zone chain.
Allocate (if not required ). Obviously, if the first idle partition cannot meet the requirements, there is no idle partition. This allocation method seems unreasonable at the beginning, but it is also very intuitive.
Attractiveness: After a program is placed in a large idle area, the remaining idle area is often large, so a large new program can be installed.
The sorting of the worst adaptive algorithm is the opposite of that of the best adaptive algorithm. Its Queue pointer always points to the largest idle zone and searches from the largest idle zone during allocation.
This algorithm overcomes many small fragments left by the best adaptive algorithm, but the possibility of retaining a large free zone is reduced, and the recovery of free zones is as complex as the best adaptive algorithm.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.