phalcon/cphalcon — pull request #893 by sjinks (2013-07-21 22:20:31+00:00)
Title: [NFR] kernel/memory.c optimizations

* do not call erealloc() on every call to phalcon_memory_observe()/phalcon_memory_alloc()
* do not waste the very first memory frame
* free the root memory frame and its structures only during RSHUTDOWN or MSHUTDOWN; this helps reduce the number of calls to emalloc()/efree()
* use ecalloc() instead of emalloc() when allocating a memory frame (no need to zero out memory)
* safe erealloc()
* number of observed variables per frame is not limited with PHALCON_MAX_MEMORY_STACK anymore

On a large scale, when running manual-unit.php, there are almost 15,000 less calls to efree(), 68,000 less calls to emalloc(), cost of the call to phalcon_memory_observe() is almost 2 times less now (tested with callgrind).