summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndi Gutmans <andi@php.net>2001-06-19 18:04:53 +0000
committerAndi Gutmans <andi@php.net>2001-06-19 18:04:53 +0000
commit31ef9e8fafd9b3684efd934c30e5125a9fe2f9e0 (patch)
tree70266dba4b924982fc322410bef7ee8ac8b4ee29
parent8ef5510aa9a0e61caea19c283ee97b8728cecd96 (diff)
downloadphp-git-31ef9e8fafd9b3684efd934c30e5125a9fe2f9e0.tar.gz
- Real MFH of memory fragmentation patch
-rw-r--r--Zend/zend_alloc.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c
index ade2d03c31..fa3f4f685d 100644
--- a/Zend/zend_alloc.c
+++ b/Zend/zend_alloc.c
@@ -394,6 +394,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()
@@ -410,6 +411,7 @@ ZEND_API void start_memory_manager(ALS_D)
}
}
#endif
+#endif
#if ZEND_DEBUG
memset(AG(cache_stats), 0, sizeof(AG(cache_stats)));
@@ -438,6 +440,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) {
@@ -478,13 +493,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;
#endif