internals:zend_mm
Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
internals:zend_mm [2011/11/30 06:09] laruence |
internals:zend_mm [2017/09/22 13:28] (current) |
||
---|---|---|---|
Line 3: | Line 3: | ||
* Date: 2011-11-09 | * Date: 2011-11-09 | ||
* Author: Xinchen Hui < | * Author: Xinchen Hui < | ||
- | * Chinese: http:// | + | * Chinese(中文版): http:// |
* First Published at: https:// | * First Published at: https:// | ||
Line 15: | Line 15: | ||
I am not good at english, so if you find some wrong words, plz feel free to edit it. | I am not good at english, so if you find some wrong words, plz feel free to edit it. | ||
===== Zend MM ===== | ===== Zend MM ===== | ||
- | Zend mm is the memory manager | + | PHP is written entirely in C. In C, the programmer is responsible for the allocation and release |
- | Zend mm divides memory into two type, small memory and large memory. | + | PHP has very specific requirements for management of memory and many modes of execution; all sharing a common set of requirements. |
- | for small memory, | + | The memory |
- | for large memory, Zend mm is very careful to avoid memory waste. | + | The memory |
+ | small: when allocating small blocks of memory, it is important that the manager is fast and efficient. | ||
+ | |||
+ | large: when allocating large blocks of memory, it is important that the manager minimizes wastage. | ||
+ | |||
+ | The developer makes allocations that have two distinct life cycles: | ||
+ | |||
+ | request: the most common type of allocation made; the developer requires the memory to service the current request | ||
+ | |||
+ | persistent: | ||
+ | |||
+ | The MM provides the following (per request) functions: | ||
+ | |||
+ | void* | ||
+ | void* | ||
+ | void* | ||
+ | void | ||
+ | |||
+ | They all share prototype and functionality with the standard C implementation, | ||
+ | |||
+ | Zend provides the following (persistence) functions: | ||
+ | |||
+ | void* pemalloc(size_t size, zend_bool persistent); | ||
+ | void* perealloc(void* pointer, size_t size, zend_bool persistent); | ||
+ | void* pecalloc(size_t num, size_t count, zend_bool persistent); | ||
+ | void pefree(void* pointer, zend_bool persistent); | ||
+ | |||
+ | Persistent memory is not optimized, or tracked by the implementation, | ||
+ | |||
+ | The following diagrams and explanations provide insight into how and why Zend MM manages the per request memory it allocates. | ||
===== Struct zend_mm_heap ===== | ===== Struct zend_mm_heap ===== | ||
<code c> | <code c> |
internals/zend_mm.1322633371.txt.gz · Last modified: 2017/09/22 13:28 (external edit)