I'm releasing an extended PHP logging extension that we currently use at facebook with much success. I currently use a small patch to determine if a memory overflow has occurred as there's currently no direct access into the allocator structures. You can get more information on the project at http://tekrat.com/php/xlog/.
It would be useful if this patch (and perhaps more accessors into the memory allocator) where added. Although I understand there should be some careful choices and limitations here, and this case is a pretty specific use case, but I thought I'd share it in case there are others who happen to find this useful as well or perhaps someone can propose a more general alternative. Patches for different branches are here (I've pasted php53 below): http://tekrat.com/downloads/bits/zend_mm_heap_overflow.php6.patch http://tekrat.com/downloads/bits/zend_mm_heap_overflow.php53.patch http://tekrat.com/downloads/bits/zend_mm_heap_overflow.php52.patch diff --git a/ZendEngine2/zend_alloc.c b/ZendEngine2/zend_alloc.c index 8853d06..b8884a0 100644 --- a/ZendEngine2/zend_alloc.c +++ b/ZendEngine2/zend_alloc.c @@ -2537,6 +2537,13 @@ ZEND_API void start_memory_manager(TSRMLS_D) #endif } +/*** BEGIN Patch: zend_mm_heap_overflow ***/ +ZEND_API int zend_mm_heap_overflow(TSRMLS_D) +{ + return AG(mm_heap)->overflow; +} +/*** END Patch: zend_mm_heap_overflow ***/ + ZEND_API zend_mm_heap *zend_mm_set_heap(zend_mm_heap *new_heap TSRMLS_DC) { zend_mm_heap *old_heap; diff --git a/ZendEngine2/zend_alloc.h b/ZendEngine2/zend_alloc.h index d92df4b..3610931 100644 --- a/ZendEngine2/zend_alloc.h +++ b/ZendEngine2/zend_alloc.h @@ -231,6 +231,7 @@ struct _zend_mm_storage { }; ZEND_API zend_mm_heap *zend_mm_startup_ex(const zend_mm_mem_handlers *handlers, size_t block_size, size_t reserve_size, int internal, void *params); +ZEND_API int zend_mm_heap_overflow(TSRMLS_D); /* Patch: zend_mm_heap_overflow */ ZEND_API zend_mm_heap *zend_mm_set_heap(zend_mm_heap *new_heap TSRMLS_DC); ZEND_API zend_mm_storage *zend_mm_get_storage(zend_mm_heap *heap); -shire -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php