diff --git a/internals2/memory/persistence.xml b/internals2/memory/persistence.xml index 389794f30e..2f16b7a555 100644 --- a/internals2/memory/persistence.xml +++ b/internals2/memory/persistence.xml @@ -1,9 +1,96 @@ - - Data persistence - + + Data persistence + + + In the context of PHP, data persistence is taken to mean any data that is intended to survive the current request. + + + + Persistence can be used, for example, to keep conntections to a database server for multiple requests, Zend provides a sub-api of its emalloc/efree mechanisms, predictably name pemalloc/pefree etc + + + + All of the following functions take the additional persistent parameter, should this be false, Zend will use it's regular allocators and the memory should not be considered persistent. Where memory is allocated as persistent, system allocators are invoked, under most circumstances they are still not able to return NULL pointers just as the Main memory APIs. - - + + + + Persistent memory APIs + + + + Prototype + Description + + + + + + void *pemalloc(size_t size, zend_bool persistent) + Allocate size bytes of memory. + + + + void *pecalloc(size_t nmemb, size_t size, zend_bool persistent) + + Allocate a buffer for nmemb elements of + size bytes and makes sure it is initialized with zeros. + + + + + void *perealloc(void *ptr, size_t size, zend_bool persistent) + + Resize the buffer ptr, which was allocated using + emalloc to hold size bytes of memory. + + + + + void pefree(void *ptr, zend_bool persistent) + + Free the buffer pointed by ptr. The buffer had to be + allocated by pemalloc. + + + + + + void *safe_pemalloc(size_t nmemb, size_t size, size_t offset, zend_bool persistent) + + + Allocate a buffer for holding nmemb blocks of each + size bytes and an additional offset bytes. + This is similar to emalloc(nmemb * size + offset) but adds + a special protection against overflows. + + + + + char *pestrdup(const char *s, zend_bool persistent) + + Allocate a buffer that can hold the NULL-terminated string + s and copy the s into that buffer. + + + + + + char *pestrndup(const char *s, unsigned int length, zend_bool persistent) + + + Similar to pestrdup while the length of the + NULL-terminated string is already known. + + + + +
+ + + It is important to remember that memory allocated to be persistent is not optimized or tracked by the Zend engine; it is not subject to memory_limit. + +