Starting from today, we will keep a record of what we have learned in the ryzom server code. We will also refer to mangos and so on. We will not write down the introduction of ryzom here, if you are interested, google. as cloud wind has repeatedly stressed, a stable and efficient mmorpg server still needs its own memory allocation mechanism. So let's take a look at ryzom's memory allocation mechanism today. all the files used below are in the misc directory. 1. CBlockMemory (block_memory.h) This is a block allocation policy. Each block of memory includes a fixed number of elements. If you still need to apply for memory after use, a new block will be allocated. The memory of a single block will not be released unless you call the purge method, release all block memory. see 650) this. width = 650; "onclick = 'window. open (" http://blog.51cto.com/viewpic.php? Refimg = "+ this. src) 'border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1K12GV0-0.png "/> 650) this. width = 650; "onclick = 'window. open (" http://blog.51cto.com/viewpic.php? Refimg = "+ this. src) 'border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1K12K4I-1.png "/> 650) this. width = 650; "onclick = 'window. open (" http://blog.51cto.com/viewpic.php? Refimg = "+ this. src) 'border' =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1K12HQ3-2.png "/> 2. CContiguousBlockAllocator (contiguous_block_allocator.h) To allocate a whole block of memory, you need to apply to this block of memory as much space as you need. If the available quantity is exceeded, you can call the standard new Method for allocation. See. 650) this. width = 650; "onclick = 'window. open (" http://blog.51cto.com/viewpic.php? Refimg = "+ this. src) 'border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1K12JP1-3.png "/> 3. CPoolMemory (pool_memory.h) Std: vector is used to pre-allocate n elements. Multiple vectors are stored in list. When released, all vectors are released and can be used to create temporary objects. For details, see 650) this. width = 650; "onclick = 'window. open (" http://blog.51cto.com/viewpic.php? Refimg = "+ this. src) 'border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/1K12HD2-4.png "/> 4. CHeapMemory (heap_memory.h) The memory allocated to the heap is managed because the standard heap allocation method is still used, so the speed has not changed. I personally think it makes a bad sense and I will not discuss it here. This is roughly the memory allocation plan used by ryzom. For a game, different allocation strategies can be used based on different needs. For example, for monsters and players in the game, npc will pre-allocate n object instances, which is the application of CBlockMemory. Therefore, you need to find out what your minimum needs are.
This article from the "high wall wide grain" blog, please be sure to keep this source http://adamgliea.blog.51cto.com/1982201/368085