diff options
| author | Zeev Suraski <zeev@php.net> | 2000-05-16 15:42:16 +0000 |
|---|---|---|
| committer | Zeev Suraski <zeev@php.net> | 2000-05-16 15:42:16 +0000 |
| commit | ac0e07ecdaa1ecda91de17784d0e0348c105c435 (patch) | |
| tree | 9a120a65d565d4972cef6a124d3a5dc54994960e /Zend/zend_alloc.c | |
| parent | 0aa5f2ea3c161e7ace096269b03e45e01e93c079 (diff) | |
| download | php-git-ac0e07ecdaa1ecda91de17784d0e0348c105c435.tar.gz | |
- Small optimization. Filling up the Cache helps performance.
Diffstat (limited to 'Zend/zend_alloc.c')
| -rw-r--r-- | Zend/zend_alloc.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index d9602c3f69..2b1034eab1 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -319,6 +319,9 @@ ZEND_API int zend_set_memory_limit(unsigned int memory_limit) ZEND_API void start_memory_manager(ALS_D) { + int i, j; + void *cached_entries[MAX_CACHED_MEMORY][MAX_CACHED_ENTRIES]; + AG(phead) = AG(head) = NULL; #if MEMORY_LIMIT @@ -334,6 +337,18 @@ 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,MAX_CACHED_MEMORY*sizeof(unsigned char)); + + /* Initialize cache, to prevent fragmentation */ + for (i=1; i<MAX_CACHED_MEMORY; i++) { + for (j=0; j<MAX_CACHED_ENTRIES; j++) { + cached_entries[i][j] = emalloc(i); + } + } + for (i=1; i<MAX_CACHED_MEMORY; i++) { + for (j=0; j<MAX_CACHED_ENTRIES; j++) { + efree(cached_entries[i][j]); + } + } } |
