diff options
| author | Andi Gutmans <andi@php.net> | 2001-06-19 17:59:07 +0000 |
|---|---|---|
| committer | Andi Gutmans <andi@php.net> | 2001-06-19 17:59:07 +0000 |
| commit | 34e0c392e8c74425204915e7fe15a5c7790e747e (patch) | |
| tree | 23625836c49afd0fc998670d904e3a0c55075a9d /Zend/zend_alloc.c | |
| parent | 746dd9cbe467868b83c3b969b9467b5e94b7afb4 (diff) | |
| download | php-git-34e0c392e8c74425204915e7fe15a5c7790e747e.tar.gz | |
- Fix memory fragmention problem which could lead to web server processes
growing much more than they should. (bug #11344?)
Diffstat (limited to 'Zend/zend_alloc.c')
| -rw-r--r-- | Zend/zend_alloc.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index 36945d5ed8..04e7ce517c 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -403,6 +403,7 @@ ZEND_API void start_memory_manager(ALS_D) memset(AG(fast_cache_list_head), 0, sizeof(AG(fast_cache_list_head))); memset(AG(cache_count), 0, sizeof(AG(cache_count))); +#if 0 #ifndef ZTS /* Initialize cache, to prevent fragmentation */ /* We can't do this in ZTS mode, because calling emalloc() from within start_memory_manager() @@ -419,6 +420,7 @@ ZEND_API void start_memory_manager(ALS_D) } } #endif +#endif #if ZEND_DEBUG memset(AG(cache_stats), 0, sizeof(AG(cache_stats))); @@ -447,6 +449,19 @@ ZEND_API void shutdown_memory_manager(int silent, int clean_cache) AG(fast_cache_list_head)[fci] = NULL; } + if (1 || clean_cache) { + zend_mem_header *ptr; + + for (i=1; i<MAX_CACHED_MEMORY; i++) { + for (j=0; j<AG(cache_count)[i]; j++) { + ptr = (zend_mem_header *) AG(cache)[i][j]; + REMOVE_POINTER_FROM_LIST(ptr); + free(ptr); + } + AG(cache_count)[i] = 0; + } + } + p = AG(head); t = AG(head); while (t) { @@ -487,13 +502,6 @@ ZEND_API void shutdown_memory_manager(int silent, int clean_cache) } } - if (clean_cache) { - for (i=1; i<MAX_CACHED_MEMORY; i++) { - for (j=0; j<AG(cache_count)[i]; j++) { - free(AG(cache)[i][j]); - } - } - } #if MEMORY_LIMIT AG(memory_exhausted)=0; AG(allocated_memory_peak) = 0; |
