2007-07-19 21:57:06 +08:00
|
|
|
Zend Memory Manager
|
|
|
|
===================
|
2006-07-19 00:54:37 +08:00
|
|
|
|
2007-07-19 21:57:06 +08:00
|
|
|
General:
|
|
|
|
--------
|
2006-07-19 00:54:37 +08:00
|
|
|
|
2007-07-19 21:57:06 +08:00
|
|
|
The goal of the new memory manager (available since PHP 5.2) is to reduce memory
|
|
|
|
allocation overhead and speedup memory management.
|
2006-07-19 00:54:37 +08:00
|
|
|
|
2007-07-19 21:57:06 +08:00
|
|
|
The new manager's "configure" has no "--disable-zend-memory-manager" option,
|
|
|
|
but it has "--enable-malloc-mm" instead. It is enabled by default in DEBUG
|
2011-08-08 15:42:58 +08:00
|
|
|
build and disabled by default in RELEASE build. When enabled it allows selecting
|
2007-07-19 21:57:06 +08:00
|
|
|
between malloc and emalloc at runtime so you can use internal and external memory
|
|
|
|
debuggers without recompilation.
|
2006-07-19 00:54:37 +08:00
|
|
|
|
2007-07-19 21:57:06 +08:00
|
|
|
Debugging:
|
|
|
|
----------
|
2006-07-19 00:54:37 +08:00
|
|
|
|
2007-07-19 21:57:06 +08:00
|
|
|
Normal:
|
2006-07-19 00:54:37 +08:00
|
|
|
|
2007-07-19 21:57:06 +08:00
|
|
|
$ sapi/cli/php -r 'leak();'
|
|
|
|
|
|
|
|
Zend MM disabled:
|
|
|
|
|
|
|
|
$ USE_ZEND_ALLOC=0 valgrind --leak-check=full sapi/cli/php -r 'leak();'
|
|
|
|
|
2011-08-08 15:42:58 +08:00
|
|
|
Shared extensions:
|
|
|
|
------------------
|
|
|
|
|
2012-03-07 02:34:10 +08:00
|
|
|
Since PHP 5.3.11 it is possible to prevent shared extensions from unloading so
|
2011-08-08 15:42:58 +08:00
|
|
|
that valgrind can correctly track the memory leaks in shared extensions. For
|
|
|
|
this there is the ZEND_DONT_UNLOAD_MODULES environment variable. If set, then
|
|
|
|
DL_UNLOAD() is skipped during the shutdown of shared extensions.
|
|
|
|
|
|
|
|
|
2007-07-19 21:57:06 +08:00
|
|
|
Tweaking:
|
|
|
|
---------
|
|
|
|
|
|
|
|
The Zend MM can be tweaked using ZEND_MM_MEM_TYPE and ZEND_MM_SEG_SIZE environment
|
|
|
|
variables. Default values are "malloc" and "256K". Dependent on target system you
|
|
|
|
can also use "mmap_anon", "mmap_zero" and "win32" storage managers.
|
|
|
|
|
|
|
|
$ ZEND_MM_MEM_TYPE=mmap_anon ZEND_MM_SEG_SIZE=1M sapi/cli/php ..etc.
|