logo       
Google Custom Search
    AddThis Social Bookmark Button

cvs: ZendEngine2(PHP_5_3) / zend_alloc.c: msg#00056

Subject: cvs: ZendEngine2(PHP_5_3) / zend_alloc.c
dmitry          Thu Oct 25 07:32:40 2007 UTC

  Modified files:              (Branch: PHP_5_3)
    /ZendEngine2        zend_alloc.c 
  Log:
  Added ability to control memory consumption between request using 
ZEND_MM_COMPACT environment variable
  
  
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_alloc.c?r1=1.144.2.3.2.43.2.1&r2=1.144.2.3.2.43.2.2&diff_format=u
Index: ZendEngine2/zend_alloc.c
diff -u ZendEngine2/zend_alloc.c:1.144.2.3.2.43.2.1 
ZendEngine2/zend_alloc.c:1.144.2.3.2.43.2.2
--- ZendEngine2/zend_alloc.c:1.144.2.3.2.43.2.1 Sat Sep 29 10:37:29 2007
+++ ZendEngine2/zend_alloc.c    Thu Oct 25 07:32:40 2007
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_alloc.c,v 1.144.2.3.2.43.2.1 2007/09/29 10:37:29 dmitry Exp $ */
+/* $Id: zend_alloc.c,v 1.144.2.3.2.43.2.2 2007/10/25 07:32:40 dmitry Exp $ */
 
 #include "zend.h"
 #include "zend_alloc.h"
@@ -406,6 +406,7 @@
        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 @@
 
        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 @@
        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 @@
                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 @@
                        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;

-- 
Zend Engine CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




<Prev in Thread] Current Thread [Next in Thread>