Bug #73659 [Opn->Nab]: Recursive call leaks memory
| From: | nikic@php.net | Date: | Mon, 05 Dec 2016 19:26:20 +0000 |
| Subject: | Bug #73659 [Opn->Nab]: Recursive call leaks memory | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-205789@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=73659&edit=1
ID: 73659
Updated by: nikic@php.net
Reported by: grzegorz129 at gmail dot com
Summary: Recursive call leaks memory
-Status: Open
+Status: Not a bug
Type: Bug
Package: Performance problem
Operating System: Linux
PHP Version: 7.1.0
Block user comment: N
Private report: N
New Comment:
memory_get_usage(true) reports memory as allocated by the memory manager. This occurs in 2MB chunks,
and these chunks may be cached. What you're seeing here is that the memory manager ends up
retaining two chunks.
To check for leaks, use memory_get_usage() without "true".
Previous Comments:
------------------------------------------------------------------------
[2016-12-05 18:47:01] grzegorz129 at gmail dot com
Description:
------------
I've found very strange behavior, which is (unfortunately) consistent across multiple PHP
versions: https://3v4l.org/ppe5R
Test script:
---------------
<?php
gc_enable();
echo memory_get_usage(true)/1024 . "\n";
function callFunc($i = 0) {
if ($i < 100000) {
gc_collect_cycles();
callFunc(++$i);
}
}
callFunc();
gc_collect_cycles();
echo memory_get_usage(true)/1024 . "\n";
callFunc();
gc_collect_cycles();
echo memory_get_usage(true)/1024 . "\n";
Expected result:
----------------
Memory should be freed after recursion.
Actual result:
--------------
Memory is retained during lifetime of a recursion, but it's never freed.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=73659&edit=1