xref: /PHP-7.3/Zend/README.ZEND_MM (revision c9436c20)
1Zend Memory Manager
2===================
3
4General:
5--------
6
7The goal of the new memory manager (available since PHP 5.2) is to reduce memory
8allocation overhead and speedup memory management.
9
10The new manager's "configure" has no "--disable-zend-memory-manager" option,
11but it has "--enable-malloc-mm" instead.  It is enabled by default in DEBUG
12build and disabled by default in RELEASE build. When enabled it allows selecting
13between malloc and emalloc at runtime so you can use internal and external memory
14debuggers without recompilation.
15
16Debugging:
17----------
18
19Normal:
20
21    $ sapi/cli/php -r 'leak();'
22
23Zend MM disabled:
24
25    $ USE_ZEND_ALLOC=0 valgrind --leak-check=full sapi/cli/php -r 'leak();'
26
27Shared extensions:
28------------------
29
30Since PHP 5.3.11 it is possible to prevent shared extensions from unloading so
31that valgrind can correctly track the memory leaks in shared extensions. For
32this there is the ZEND_DONT_UNLOAD_MODULES environment variable. If set, then
33DL_UNLOAD() is skipped during the shutdown of shared extensions.
34
35
36Tweaking:
37---------
38
39The Zend MM can be tweaked using ZEND_MM_MEM_TYPE and ZEND_MM_SEG_SIZE environment
40variables.  Default values are "malloc" and "256K". Dependent on target system you
41can also use "mmap_anon", "mmap_zero" and "win32" storage managers.
42
43	$ ZEND_MM_MEM_TYPE=mmap_anon ZEND_MM_SEG_SIZE=1M sapi/cli/php ..etc.
44