Bug #76523 [Com]: PHP Leaks memory when utilizing objects
| From: | mimipim at abv dot bg | Date: | Sun, 24 Jun 2018 16:10:06 +0000 |
| Subject: | Bug #76523 [Com]: PHP Leaks memory when utilizing objects | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-215954@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=76523&edit=1
ID: 76523
Comment by: mimipim at abv dot bg
Reported by: mimipim at abv dot bg
Summary: PHP Leaks memory when utilizing objects
Status: Open
Type: Bug
Package: Performance problem
Operating System: CentOS, Debian, Maybe any
PHP Version: 7.2.7
Block user comment: N
Private report: N
New Comment:
According to debug data collected with the meminfo extension it seems that the problem is not actual
memory leakage but instead the memory_get_usage function is not reporting correct number. Only
experts on PHP's code would be able to tell what is the case.
Previous Comments:
------------------------------------------------------------------------
[2018-06-24 15:27:00] mimipim at abv dot bg
This is minimized script for reproduction: https://3v4l.org/dSB4T
<?php
class NonLeakingClass
{
}
//echo "Test empty object memory leakage" . PHP_EOL; // WARNING: Uncomment this line and
PHP stops to leak memory on object creation, strange :)
for ($h = 0; $h < 5; $h++) {
var_dump(memory_get_usage(false));
$a = new NonLeakingClass();
unset($a);
gc_collect_cycles();
var_dump(memory_get_usage(false));
}
exit;
------------------------------------------------------------------------
[2018-06-24 15:25:36] mimipim at abv dot bg
Description:
------------
I have found that PHP leaks memory simply by creating empty class object.
The leakage happens only on first initiation of the exact class type, each next new object will not
leak any more.
Test script:
---------------
Check out the live test script: https://3v4l.org/T5qsG
It shows you that after initialization of the fist object and destroying it the memory is not freed
up. Strangely if you uncomment the echo statement the leakage is not appearing. HHVM reports the
same memory in all cases, just as expected.
Expected result:
----------------
All memory reports to show the same memory usage.
Actual result:
--------------
After the first memory report are following reports of used RAM bigger than expected.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=76523&edit=1