memory pool

/* The main components of the memory consumption are: 1. buffer pool, 2. parsed and optimized SQL statements, 3. data dictionary cache, 4. log buffer, 5. locks for each transaction, 6. hash table for the adaptive index, 7. state and buffers for each SQL query currently being executed, 8. session for each user, and 9. stack for each OS thread. Items 1 and 2 are managed by an LRU algorithm. Items 5 and 6 can potentially consume very much memory. Items 7 and 8 should consume quite little memory, and the OS should take care of item 9, which too should consume little memory. */ /** Data structure for a memory pool. The space is allocated using the buddy algorithm, where free list i contains areas of size 2 to power i. */ struct mem_pool_struct{ byte* buf; /*!< memory pool */ ulint size; /*!< memory common pool size */ ulint reserved; /*!< amount of currently allocated memory */ mutex_t mutex; /*!< mutex protecting this struct */ UT_LIST_BASE_NODE_T(mem_area_t) free_list[64]; /*!< lists of free memory areas: an area is put to the list whose number is the 2-logarithm of the area size */ }; /** Memory area header */ struct mem_area_struct{ ulint size_and_free; /*!< memory area size is obtained by anding with ~MEM_AREA_FREE; area in a free list if ANDing with MEM_AREA_FREE results in nonzero */ UT_LIST_NODE_T(mem_area_t) free_list; /*!< free list node */ };

 

 

 分配一整块内存,按2的幂组织成小块,需要时去最近的小块去找,就是 buddy algorithm, 每块分配的内存前面放个mem_area_struct,这个是对运气过程中分配内存结构体用的,不是用于存页面缓冲的,相当于malloc和free

你可能感兴趣的:(struct,list,each,Dictionary,Components,structure)