Skip to content

Commit 4388df9

Browse files
author
Julien Pauli
committed
ZendMM additions
1 parent 7f8c1d4 commit 4388df9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Book/php7/memory_management/zend_memory_manager.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ strings.
124124
Whatever happens, pointers returned by ZendMM must be freed using ZendMM, aka ``efree()`` call and
125125
**not libc's free()**.
126126

127+
.. note:: A note on persistent allocations. Persistent allocations stay alive between requests. You traditionnaly use
128+
the common libc ``malloc/free`` to perform that, but ZendMM has got some shortcuts to libc allocator : the
129+
"persistent" API. This API starts by the *"p"* letter, hence a ``pemalloc()`` is nothing more than a
130+
``malloc()``, a ``pefree()`` is a ``free()`` and a ``pestrdup()`` is a ``strdup()``. Just to say.
131+
127132
Zend Memory Manager debugging shields
128133
*************************************
129134

@@ -217,7 +222,8 @@ Here are the most common errors while using ZendMM, and what you should do about
217222

218223
Get infos about
219224
:doc:`the PHP lifecycle <../extensions_design/php_lifecycle>` to know in your extensions when you are treating a
220-
request, and when not.
225+
request, and when not. If you use ZendMM out of the scope of a request (like in ``MINIT()``), the allocation will be
226+
silently cleared by ZendMM before treating the first request, and you'll probably use-after-free : simply don't.
221227

222228
2. Buffer overflow and underflows.
223229

0 commit comments

Comments
 (0)