Bug #73960 [Com]: Leak with instance method calling static method with referenced return
| From: | danack@php.net | Date: | Thu, 19 Jan 2017 21:38:17 +0000 |
| Subject: | Bug #73960 [Com]: Leak with instance method calling static method with referenced return | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-206749@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=73960&edit=1
ID: 73960
Comment by: danack@php.net
Reported by: highmind63 at gmail dot com
Summary: Leak with instance method calling static method with
referenced return
Status: Open
Type: Bug
Package: Class/Object related
Operating System: Windows 10 and Ubuntu 14.04
PHP Version: 7.0.15
Block user comment: N
Private report: N
New Comment:
This apparently affects 7.0.x but not 7.1.x
https://3v4l.org/XBPgY
Previous Comments:
------------------------------------------------------------------------
[2017-01-19 18:05:46] highmind63 at gmail dot com
Description:
------------
Memory leaks with referenced variable return in static method called by instance method.
Test script:
---------------
<pre>
<?php
class Leak {
static protected function &leaked(array &$array = null) {
$array = array('one');
return $array;
}
public function toLeaked($array = null) {
$array = static::leaked($array);
return $array;
}
public function testLeak() {
echo "memory before loop: " . memory_get_usage(true) . PHP_EOL;
for ($i = 0; $i < 5000; $i++) {
$leak = $this->toLeaked();
}
echo "memory after loop: " . memory_get_usage(true) . PHP_EOL;
}
}
$leak = new Leak();
$leak->testLeak();
?>
</pre>
Expected result:
----------------
No Leak
Actual result:
--------------
Leaks Memory:
memory before loop: 2097152
memory after loop: 4194304
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=73960&edit=1