@@ -394,6 +394,7 @@ ZEND_API void start_memory_manager(ALS_D)
394
394
memset (AG (fast_cache_list_head ), 0 , sizeof (AG (fast_cache_list_head )));
395
395
memset (AG (cache_count ), 0 , sizeof (AG (cache_count )));
396
396
397
+ #if 0
397
398
#ifndef ZTS
398
399
/* Initialize cache, to prevent fragmentation */
399
400
/* 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)
410
411
}
411
412
}
412
413
#endif
414
+ #endif
413
415
414
416
#if ZEND_DEBUG
415
417
memset (AG (cache_stats ), 0 , sizeof (AG (cache_stats )));
@@ -438,6 +440,19 @@ ZEND_API void shutdown_memory_manager(int silent, int clean_cache)
438
440
AG (fast_cache_list_head )[fci ] = NULL ;
439
441
}
440
442
443
+ if (1 || clean_cache ) {
444
+ zend_mem_header * ptr ;
445
+
446
+ for (i = 1 ; i < MAX_CACHED_MEMORY ; i ++ ) {
447
+ for (j = 0 ; j < AG (cache_count )[i ]; j ++ ) {
448
+ ptr = (zend_mem_header * ) AG (cache )[i ][j ];
449
+ REMOVE_POINTER_FROM_LIST (ptr );
450
+ free (ptr );
451
+ }
452
+ AG (cache_count )[i ] = 0 ;
453
+ }
454
+ }
455
+
441
456
p = AG (head );
442
457
t = AG (head );
443
458
while (t ) {
@@ -478,13 +493,6 @@ ZEND_API void shutdown_memory_manager(int silent, int clean_cache)
478
493
}
479
494
}
480
495
481
- if (clean_cache ) {
482
- for (i = 1 ; i < MAX_CACHED_MEMORY ; i ++ ) {
483
- for (j = 0 ; j < AG (cache_count )[i ]; j ++ ) {
484
- free (AG (cache )[i ][j ]);
485
- }
486
- }
487
- }
488
496
#if MEMORY_LIMIT
489
497
AG (memory_exhausted )= 0 ;
490
498
#endif
0 commit comments