Skip to content

Track heap->real_size for USE_TRACKED_ALLOC #18880

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Zend/zend_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2256,6 +2256,7 @@ void zend_mm_shutdown(zend_mm_heap *heap, bool full, bool silent)
heap->custom_heap.std._free = free;
}
heap->size = 0;
heap->real_size = 0;
}

if (full) {
Expand Down Expand Up @@ -2799,6 +2800,7 @@ static void *tracked_malloc(size_t size)
void *ptr = __zend_malloc(size);
tracked_add(heap, ptr, size);
heap->size += size;
heap->real_size = heap->size;
return ptr;
}

Expand All @@ -2810,6 +2812,7 @@ static void tracked_free(void *ptr) {
zend_mm_heap *heap = AG(mm_heap);
zval *size_zv = tracked_get_size_zv(heap, ptr);
heap->size -= Z_LVAL_P(size_zv);
heap->real_size = heap->size;
zend_hash_del_bucket(heap->tracked_allocs, (Bucket *) size_zv);
free(ptr);
}
Expand All @@ -2835,6 +2838,7 @@ static void *tracked_realloc(void *ptr, size_t new_size) {
ptr = __zend_realloc(ptr, new_size);
tracked_add(heap, ptr, new_size);
heap->size += new_size - old_size;
heap->real_size = heap->size;
return ptr;
}

Expand Down
Loading