memcache -- memory allocation
来源:互联网 发布:ff14拉拉菲尔捏脸数据 编辑:程序博客网 时间:2024/05/29 19:32
why use slab allocation:
problem allocating memory:
cause data in memory changes constantly and not in fixed size, so there will be lots of fragments in memory that is too small to use ,it will cause a wast of memory ,so memcache use slab allocation to allocate memory.
slab allocation:
the memory is divided into several slabs, each slab consist of serveral chunks of fixed size, as the precedding diagram indicates, when an object requires a 50 bytes of memory it will be allocated into slab class1, and a 120 bytes object will be allocated into slab class 3. but this will also cost a little waste of memory:
in this case a memory of 28 bytes is wasted(indicated by blue shadow in the diagram).
Growth Factor
the chunk sized grows in an fixed pace. how fast the chunck wil grows is specified by grow factor and you can set growth factor by -f parameter . as the precedding diagram of slabs indicates :112=1.25*88 144=1.25*112 in this case 1.25 is growth factor (f).
the size of growth factor should be appropriately settd , and 1.25 is the default growth factor of memcache ,and works well in most cases.
what happens when run out of chunks;
consider this, you need to allocate an object of 120 bytes ,normally you will allocate it in slab class 3 whose chunk size is 144 bytes. but it happens when you have no more empty chunks in slab class 3. what will memcache do in this case.
it will release some trunks in slab class 3 in some rule to get empty chunks.
0 0
- memcache -- memory allocation
- Memory Allocation
- Memory allocation with strings
- DomUs and memory allocation
- Windows Memory Allocation Limitations
- Advanced Memory Allocation
- memory allocation manager
- Advanced Memory Allocation
- Dynamic memory allocation example
- C++: Custom memory allocation
- Kernel Memory Allocation
- Memory Allocation of C++
- Mali & UMP memory allocation
- Geeksquiz | Dynamic Memory Allocation
- KVM max memory allocation
- aligned memory allocation
- Mysql Memory Allocation
- dynamic memory allocation
- 设计包含min函数的栈
- 加密 解密 函数
- 严蔚敏 数据结构 算法6.5
- HDU 1533 Going Home【km应用】
- 小文件解决方案
- memcache -- memory allocation
- 阿斯顿肺结核房管局股份好几个复活节
- MySQL启动分析 --> /MySQL5.6/sql/mysqld.cc
- 游戏开发(三)——WIN32 黑白棋(一)——棋局逻辑的设计
- 数据结构和算法设计专题之---求子数组和的最大值
- Python中的psutil:一个用于获得处理器和系统相关信息的模块
- 【map<s,i>】#42 A. Football
- ios 知识小积累
- POJ 3253 Fence Repair