Skip to content

Commit bf774d4

Browse files
committed
Reduce amount of updated memory
1 parent 4887896 commit bf774d4

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

Zend/zend_alloc.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2274,8 +2274,6 @@ void zend_mm_shutdown(zend_mm_heap *heap, int full, int silent)
22742274
/* free the first chunk */
22752275
zend_mm_chunk_free(heap, heap->main_chunk, ZEND_MM_CHUNK_SIZE);
22762276
} else {
2277-
zend_mm_heap old_heap;
2278-
22792277
/* free some cached chunks to keep average count */
22802278
heap->avg_chunks_count = (heap->avg_chunks_count + (double)heap->peak_chunks_count) / 2.0;
22812279
while ((double)heap->cached_chunks_count + 0.9 > heap->avg_chunks_count &&
@@ -2295,30 +2293,32 @@ void zend_mm_shutdown(zend_mm_heap *heap, int full, int silent)
22952293
}
22962294

22972295
/* reinitialize the first chunk and heap */
2298-
old_heap = *heap;
22992296
p = heap->main_chunk;
2300-
memset(p, 0, ZEND_MM_FIRST_PAGE * ZEND_MM_PAGE_SIZE);
2301-
*heap = old_heap;
2302-
memset(heap->free_slot, 0, sizeof(heap->free_slot));
2303-
heap->main_chunk = p;
23042297
p->heap = &p->heap_slot;
23052298
p->next = p;
23062299
p->prev = p;
23072300
p->free_pages = ZEND_MM_PAGES - ZEND_MM_FIRST_PAGE;
23082301
p->free_tail = ZEND_MM_FIRST_PAGE;
2309-
p->free_map[0] = (1L << ZEND_MM_FIRST_PAGE) - 1;
2310-
p->map[0] = ZEND_MM_LRUN(ZEND_MM_FIRST_PAGE);
2311-
heap->chunks_count = 1;
2312-
heap->peak_chunks_count = 1;
2313-
heap->last_chunks_delete_boundary = 0;
2314-
heap->last_chunks_delete_count = 0;
2302+
p->num = 0;
2303+
2304+
#if ZEND_MM_STAT
2305+
heap->size = heap->peak = 0;
2306+
#endif
2307+
memset(heap->free_slot, 0, sizeof(heap->free_slot));
23152308
#if ZEND_MM_STAT || ZEND_MM_LIMIT
23162309
heap->real_size = ZEND_MM_CHUNK_SIZE;
23172310
#endif
23182311
#if ZEND_MM_STAT
23192312
heap->real_peak = ZEND_MM_CHUNK_SIZE;
2320-
heap->size = heap->peak = 0;
23212313
#endif
2314+
heap->chunks_count = 1;
2315+
heap->peak_chunks_count = 1;
2316+
heap->last_chunks_delete_boundary = 0;
2317+
heap->last_chunks_delete_count = 0;
2318+
2319+
memset(p->free_map, 0, sizeof(p->free_map) + sizeof(p->map));
2320+
p->free_map[0] = (1L << ZEND_MM_FIRST_PAGE) - 1;
2321+
p->map[0] = ZEND_MM_LRUN(ZEND_MM_FIRST_PAGE);
23222322
}
23232323
}
23242324

0 commit comments

Comments
 (0)