summaryrefslogtreecommitdiff
path: root/Zend
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@php.net>2007-10-25 07:32:40 +0000
committerDmitry Stogov <dmitry@php.net>2007-10-25 07:32:40 +0000
commit46dc96f3e07a38b86b05f005eda8dd67f1d721dc (patch)
treef12dc87120d4d153009a5e7ede8ac93d6246741c /Zend
parent6f7b738b712f234ec34a1e905572530bc277c8ca (diff)
downloadphp-git-46dc96f3e07a38b86b05f005eda8dd67f1d721dc.tar.gz
Added ability to control memory consumption between request using ZEND_MM_COMPACT environment variable
Diffstat (limited to 'Zend')
-rw-r--r--Zend/zend_alloc.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c
index 55827ae243..0cd9c6955b 100644
--- a/Zend/zend_alloc.c
+++ b/Zend/zend_alloc.c
@@ -406,6 +406,7 @@ struct _zend_mm_heap {
size_t free_bitmap;
size_t large_free_bitmap;
size_t block_size;
+ size_t compact_size;
zend_mm_segment *segments_list;
zend_mm_storage *storage;
size_t real_size;
@@ -1038,6 +1039,7 @@ ZEND_API zend_mm_heap *zend_mm_startup_ex(const zend_mm_mem_handlers *handlers,
heap->storage = storage;
heap->block_size = block_size;
+ heap->compact_size = 0;
heap->segments_list = NULL;
zend_mm_init(heap);
# if ZEND_MM_CACHE_STAT
@@ -1088,6 +1090,7 @@ ZEND_API zend_mm_heap *zend_mm_startup(void)
char *mem_type = getenv("ZEND_MM_MEM_TYPE");
char *tmp;
const zend_mm_mem_handlers *handlers;
+ zend_mm_heap *heap;
if (mem_type == NULL) {
i = 0;
@@ -1119,7 +1122,16 @@ ZEND_API zend_mm_heap *zend_mm_startup(void)
seg_size = ZEND_MM_SEG_SIZE;
}
- return zend_mm_startup_ex(handlers, seg_size, ZEND_MM_RESERVE_SIZE, 0, NULL);
+ heap = zend_mm_startup_ex(handlers, seg_size, ZEND_MM_RESERVE_SIZE, 0, NULL);
+ if (heap) {
+ tmp = getenv("ZEND_MM_COMPACT");
+ if (tmp) {
+ heap->compact_size = zend_atoi(tmp, 0);
+ } else {
+ heap->compact_size = 2 * 1024 * 1024;
+ }
+ }
+ return heap;
}
#if ZEND_DEBUG
@@ -1570,7 +1582,10 @@ ZEND_API void zend_mm_shutdown(zend_mm_heap *heap, int full_shutdown, int silent
free(heap);
}
} else {
- storage->handlers->compact(storage);
+ if (heap->compact_size &&
+ heap->real_peak > heap->compact_size) {
+ storage->handlers->compact(storage);
+ }
heap->segments_list = NULL;
zend_mm_init(heap);
heap->real_size = 0;