Buddy System (partner system) algorithm in heap management algorithm ___ algorithm

Source: Internet
Author: User

In a buddy system algorithm, the heap manager allocates only a specific chunk of memory to be a permitted size. For each permitted size, there is an idle list to maintain.

Generally these sizes will choose the power of 2, or Fibonacci sequence. This makes it easy to divide the number of other numbers except the smallest to two permitted size.

When the heap manager that is responsible for allocating memory receives a memory request of the size of S, it speaks of S-aligned to a permitted size. Then allocate a chunk of memory from that permitted size's free list to him. If the memory is not found in that free list, a memory is allocated to the user at a large level of memory, and the remaining half is then suspended to the permitted size's free list.

The free list in this algorithm is usually implemented by bitmap (bitmap) algorithm. This can make memory collection merging very efficient.

In the Zend engine of the heap management algorithm used in the partner system algorithm, we look at the ZEND_MM_HEAP structure of the relevant data structures:

Zend_mm_free_block *free_buckets[zend_mm_num_buckets*2];

This free_buckets is a two-bit array of free linked lists. Zend_mm_num_buckets defines the maximum power value at the time of allocation. Each power value corresponds to a *free_buckets, which is an idle list.

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.