Closed as not planned
Closed as not planned
Description
Description
When I run the following script:
<?php
// Ten loops
for ($i = 0; $i < 10; $i++) {
$test = new Test();
$test->test_function();
echo memory_get_usage()."\n";
}
class Test {
public $data = '';
public function __construct() {
}
public function test_function() {
// Generate 4 MB data inside the object
$this->data = str_repeat('a', 4*1024*1024);
self::test_function2($this);
}
public static function test_function2($object) {
//echo 'Hello'; // Enable this to prevent memory leak
return;
}
}
?>
from the command line interface I get the following output:
4591128
4591160
4591160
4591160
4591160
4591160
4591160
4591160
4591160
4591160
which is the expected output. (Memory use is constant).
When I run it through PHP-FPM I get this output:
4553128
8751608
12950088
17148568
21347048
25545528
29744008
33942488
38140968
42339448
...which indicate that memory is leaking.
If I enable the echo line, memory will not leak anymore.
Tested on PHP 8.1.2 running on Ubuntu Linux 22.04.1
(Sorry I cannot test on newest version, but I have looked through closed issues to see if someone reported something similar).
PHP Version
PHP 8.1.2
Operating System
Ubuntu 22.04.1