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 [2013/01/22 13:07] krakjoe [Zend MM] just a bit more detail |
internals:zend_mm [2017/09/22 13:28] (current) |
||
---|---|---|---|
Line 17: | Line 17: | ||
PHP is written entirely in C. In C, the programmer is responsible for the allocation and release of memory during runtime. | PHP is written entirely in C. In C, the programmer is responsible for the allocation and release of memory during runtime. | ||
- | PHP has very specific requirements for management of memory and many modes of execution; all sharing | + | PHP has very specific requirements for management of memory and many modes of execution; all sharing |
The memory manager in PHP, named Zend MM, facilitates these requirements in the same way, whatever the mode of execution, whatever the code. | The memory manager in PHP, named Zend MM, facilitates these requirements in the same way, whatever the mode of execution, whatever the code. | ||
Line 27: | Line 27: | ||
large: when allocating large blocks of memory, it is important that the manager minimizes wastage. | large: when allocating large blocks of memory, it is important that the manager minimizes wastage. | ||
- | The MM provides the following (basic) functions: | + | 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* | ||
Line 34: | Line 40: | ||
void | void | ||
- | They all share prototype and functionality with the standard C implementation, | + | They all share prototype and functionality with the standard C implementation, |
- | + | ||
- | The MM provides the following persistence functions: | + | |
- | void* pemalloc(size_t size); | + | Zend provides the following |
- | void* perealloc(void* pointer, size_t size); | + | |
- | void* pecalloc(size_t num, size_t count); | + | |
- | void pefree(void* pointer); | + | |
- | Persistent memory is not managed, optimized, or tracked by the implementation, and should only be used if the developer requires a structure to survive requests. | + | 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); | ||
- | The following diagrams and explanations provide insight into how and why Zend MM works the way it does. | + | 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.1358860052.txt.gz · Last modified: 2017/09/22 13:28 (external edit)