Skip to content

Commit 3efcffc

Browse files
fix gc with custom gc
1 parent ed36539 commit 3efcffc

1 file changed

Lines changed: 23 additions & 10 deletions

File tree

Zend/zend_alloc.c

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2135,18 +2135,18 @@ ZEND_API size_t zend_mm_gc(zend_mm_heap *heap)
21352135
if (heap->use_custom_heap & ~ZEND_MM_CUSTOM_HEAP_OBSERVED) {
21362136
size_t (*gc)(void) = heap->custom_heap._gc;
21372137
if (gc) {
2138-
return gc();
2138+
collected = gc();
21392139
}
2140-
return 0;
2141-
}
2142-
if (heap->use_custom_heap & ZEND_MM_CUSTOM_HEAP_OBSERVED) {
2143-
zend_mm_observer *current = heap->observers;
2144-
while (current != NULL) {
2145-
if (current->gc != NULL) {
2146-
current->gc(collected);
2140+
if (heap->use_custom_heap & ZEND_MM_CUSTOM_HEAP_OBSERVED) {
2141+
zend_mm_observer *current = heap->observers;
2142+
while (current != NULL) {
2143+
if (current->gc != NULL) {
2144+
current->gc(collected);
2145+
}
2146+
current = current->next;
21472147
}
2148-
current = current->next;
21492148
}
2149+
return collected;
21502150
}
21512151
#endif
21522152

@@ -2252,7 +2252,20 @@ ZEND_API size_t zend_mm_gc(zend_mm_heap *heap)
22522252
}
22532253
} while (chunk != heap->main_chunk);
22542254

2255-
return collected * ZEND_MM_PAGE_SIZE;
2255+
size_t collected_bytes = collected * ZEND_MM_PAGE_SIZE;
2256+
#if ZEND_MM_CUSTOM
2257+
if (heap->use_custom_heap & ZEND_MM_CUSTOM_HEAP_OBSERVED) {
2258+
zend_mm_observer *current = heap->observers;
2259+
while (current != NULL) {
2260+
if (current->gc != NULL) {
2261+
current->gc(collected_bytes);
2262+
}
2263+
current = current->next;
2264+
}
2265+
}
2266+
#endif
2267+
2268+
return collected_bytes;
22562269
}
22572270

22582271
#if ZEND_DEBUG

0 commit comments

Comments
 (0)