Memcached memory allocation mechanism and memcached Allocation Mechanism

Source: Internet
Author: User

Memcached memory allocation mechanism and memcached Allocation Mechanism

In C, when malloc is used to allocate memory, memory fragments are generated, that is, idle and fragmented space cannot be used.

The Slab Allocator mechanism in Memcached relieves this problem.

Basic Principles:

According to the pre-defined size, the memory is divided into several slab warehouses, and each warehouse is divided into chunks of specific length, and the chunks of the same size are divided into groups, to completely solve the memory fragmentation problem

Memcached selects the slab that best fits the data size based on the size of the received data. Memcached saves the list of idle chunks in slab, selects a chunk based on the list, and then caches the data in it.

Set the growth Factor (Grow Factor) Between Blocks Based on the variation rules of the cache data size ):


The default value is 1.25.

 

Related Article

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.