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.