Bug #77209 [Fbk->NoF]: Leaks memory

From: Date: Sun, 09 Dec 2018 04:22:04 +0000
Subject: Bug #77209 [Fbk->NoF]: Leaks memory
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-218349@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77209&edit=1 ID: 77209 Updated by: php-bugs@lists.php.net Reported by: silicid at gmail dot com Summary: Leaks memory -Status: Feedback +Status: No Feedback Type: Bug Package: Performance problem Operating System: Debian 8 PHP Version: 7.2.12 Private report: N New Comment: No feedback was provided. The bug is being suspended because we assume that you are no longer experiencing the problem. If this is not the case and you are able to provide the information that was requested earlier, please do so and change the status of the bug back to "Re-Opened". Thank you. Previous Comments: ------------------------------------------------------------------------ [2018-11-27 14:05:04] silicid at gmailc dot om It depends on the number of objects created. The output for me is: int(37336) int(3733600) int(0) int(3808384) int(3733600) int(0) int(7579320) int(3733600) int(0) int(11350256) int(3733600) int(0) int(15121192) int(3733600) int(0) int(18892128) int(3733600) int(0) int(22663064) int(3733600) int(0) int(26434000) int(3733600) int(0) int(30204936) int(3733600) int(0) int(33975872) int(3733600) int(0)... ------------------------------------------------------------------------ [2018-11-27 13:39:35] danack@php.net please could you check again, with code like the below as I don't think the garbage collection kicks in immediately every single time, and also if it is actually a memory leak, the memory usage should continue to go up, rather than just be slightly higher for a moment. The output of the script below for me is: int(0) int(0) int(32) int(0) int(0) int(32) int(0) int(0) int(32)... https://3v4l.org/dPZ2R class Test { public function __construct() { for ($i = 0; $i < 1000; ++$i) { $this->result[] = rand(1, 1000); } } function object() { is_object($this); } } function checkMemory($memoryAtStart) { for ($i = 0; $i < 1; ++$i) { $object = new Test(); $object->object(); unset($object); } var_dump(memory_get_usage() - $memoryAtStart); $memoryAtStart = memory_get_usage(); for ($i = 0; $i < 100; ++$i) { $object = new Test(); $object->object(); unset($object); } var_dump(memory_get_usage() - $memoryAtStart); $memoryAtStart = memory_get_usage(); for ($i = 0; $i < 100; ++$i) { $object = new Test(); is_object($object); unset($object); } var_dump(memory_get_usage() - $memoryAtStart); } $memoryAtStart = null; for ($x=0; $x<100; $x++) { if ($memoryAtStart === null) { $memoryAtStart = memory_get_usage(); } checkMemory($memoryAtStart); gc_collect_cycles(); } ------------------------------------------------------------------------ [2018-11-27 13:20:12] silicid at gmailc dot om PHP Version 7.2.12-1+0~20181112102353.11+jessie~1.gbp55f215 System Linux VV10015-z2174 4.15.17-3-pve #1 SMP PVE 4.15.17-13 (Mon, 18 Jun 2018 17:15:04 +0200) x86_64 Build Date Nov 12 2018 13:46:27 ------------------------------------------------------------------------ [2018-11-27 12:09:57] silicid at gmail dot com Description: ------------ You must create a file with the specified code. If you execute method "is_object" from "$this" and unset the object, then leaks memory. But if you call method "is_object" for "$object", then there are no problems. In version 7.1 there are no problems. There are no problems in Windows. Test script: --------------- <?php class Test { public function __construct() { for ($i = 0; $i < 1000; ++$i) { $this->result[] = rand(1, 1000); } } function object() { is_object($this); } } $memory = memory_get_usage(); for ($i = 0; $i < 1; ++$i) { $object = new Test(); $object->object(); unset($object); } var_dump(memory_get_usage() - $memory); $memory = memory_get_usage(); for ($i = 0; $i < 100; ++$i) { $object = new Test(); $object->object(); unset($object); } var_dump(memory_get_usage() - $memory); $memory = memory_get_usage(); for ($i = 0; $i < 100; ++$i) { $object = new Test(); is_object($object); unset($object); } var_dump(memory_get_usage() - $memory); Expected result: ---------------- int(0) int(0) int(0) Actual result: -------------- int(37336) int(3733600) int(0) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=77209&edit=1

« previous php.bugs (#218349) next »