com php-src: Fixed reporting about repeatable "huge" memory leaks.: Zend/zend_alloc.c
| From: | Dmitry Stogov | Date: | Tue, 22 Sep 2015 12:46:41 +0000 |
| Subject: | com php-src: Fixed reporting about repeatable "huge" memory leaks.: Zend/zend_alloc.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-89108@lists.php.net to get a copy of this message | ||
Commit: c61604b9a94c45550501d205afc8754ce90f525a
Author: Dmitry Stogov <dmitry@zend.com> Tue, 22 Sep 2015 15:46:41 +0300
Parents: a9bbe5c3847caa06d74ea07a790775246c9ab3ef
Branches: PHP-7.0 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=c61604b9a94c45550501d205afc8754ce90f525a
Log:
Fixed reporting about repeatable "huge" memory leaks.
Changed paths:
M Zend/zend_alloc.c
Diff:
diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c
index bd3fe0e..93061cf 100644
--- a/Zend/zend_alloc.c
+++ b/Zend/zend_alloc.c
@@ -2014,6 +2014,27 @@ static zend_long zend_mm_find_leaks(zend_mm_heap *heap, zend_mm_chunk *p, int
i,
return count;
}
+static zend_long zend_mm_find_leaks_huge(zend_mm_heap *heap, zend_mm_huge_list *list)
+{
+ zend_long count = 0;
+ zend_mm_huge_list *prev = list;
+ zend_mm_huge_list *p = list->next;
+
+ while (p) {
+ if (p->dbg.filename == list->dbg.filename && p->dbg.lineno ==
list->dbg..lineno) {
+ prev->next = p->next;
+ zend_mm_chunk_free(heap, p->ptr, p->size);
+ zend_mm_free_heap(heap, p, NULL, 0, NULL, 0);
+ count++;
+ } else {
+ prev = p;
+ }
+ p = prev->next;
+ }
+
+ return count;
+}
+
static void zend_mm_check_leaks(zend_mm_heap *heap)
{
zend_mm_huge_list *list;
@@ -2028,8 +2049,6 @@ static void zend_mm_check_leaks(zend_mm_heap *heap)
while (list) {
zend_mm_huge_list *q = list;
- heap->huge_list = list->next;
-
leak.addr = list->ptr;
leak.size = list->dbg.size;
leak.filename = list->dbg.filename;
@@ -2039,13 +2058,13 @@ static void zend_mm_check_leaks(zend_mm_heap *heap)
zend_message_dispatcher(ZMSG_LOG_SCRIPT_NAME, NULL);
zend_message_dispatcher(ZMSG_MEMORY_LEAK_DETECTED, &leak);
-//??? repeated = zend_mm_find_leaks_huge(segment, p);
+ repeated = zend_mm_find_leaks_huge(heap, list);
total += 1 + repeated;
if (repeated) {
zend_message_dispatcher(ZMSG_MEMORY_LEAK_REPEATED, (void *)(zend_uintptr_t)repeated);
}
- list = list->next;
+ heap->huge_list = list = list->next;
zend_mm_chunk_free(heap, q->ptr, q->size);
zend_mm_free_heap(heap, q, NULL, 0, NULL, 0);
}