Bug #76488 [ReO->Csd]: Memory leak when fetching a BLOB field

From: Date: Sun, 22 Jul 2018 11:50:44 +0000
Subject: Bug #76488 [ReO->Csd]: Memory leak when fetching a BLOB field
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-216392@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76488&edit=1 ID: 76488 Updated by: nikic@php.net Reported by: sim-mail at list dot ru Summary: Memory leak when fetching a BLOB field -Status: Re-Opened +Status: Closed Type: Bug Package: PDO Firebird Operating System: Any OS PHP Version: 7.2.6 -Assigned To: +Assigned To: nikic Block user comment: N Private report: N New Comment: ab pointed out that is is already in 7.1/7.2, I got confused by the (apparently still broken) GH branch listing. Previous Comments: ------------------------------------------------------------------------ [2018-07-22 11:31:36] nikic@php.net Reopened to track backports. ------------------------------------------------------------------------ [2018-07-06 14:10:41] ab@php.net Automatic comment on behalf of sim-mail@list.ru Revision: http://git.php.net/?p=php-src.git;a=commit;h=3847a6fcb63c362548e9434b195232f2dcf7a6c7 Log: Fix bug #76488 Memory leak when fetching a BLOB field ------------------------------------------------------------------------ [2018-06-17 13:17:05] sim-mail at list dot ru Description: ------------ Affects Versions: 7.0.x, 7.1.x, 7.2.x Memory leak when fetching a BLOB field Test script: --------------- <?php try { $dbh = new \PDO('firebird:dbname=localhost:employee', 'SYSDBA', 'masterkey'); $dbh->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); $dbh->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false); $dbh->setAttribute(\PDO::ATTR_CASE, \PDO::CASE_NATURAL); $sql = ' with recursive r(n) as ( select 1 from rdb$database union all select n+1 from r where n < 1000 ) select n, cast(lpad(\'A\', 8000, \'A\') as BLOB sub_type TEXT) as SRC from r '; echo "First used: " . memory_get_usage(true) . "<br>"; for ($i = 0; $i < 20; $i++) { $sth = $dbh->prepare($sql); $sth->execute(); $rows = $sth->fetchAll(); unset($rows); unset($sth); echo "$i itteration used: " . memory_get_usage(true) . "<br>"; } unset($dbh); echo "Last used: " . memory_get_usage(true) . "<br>"; } catch(Exception $e) { var_dump($e); } Expected result: ---------------- First used: 2097152 0 itteration used: 2097152 1 itteration used: 2097152 2 itteration used: 2097152 3 itteration used: 2097152 4 itteration used: 2097152 5 itteration used: 2097152 6 itteration used: 2097152 7 itteration used: 2097152 8 itteration used: 2097152 9 itteration used: 2097152 10 itteration used: 2097152 11 itteration used: 2097152 12 itteration used: 2097152 13 itteration used: 2097152 14 itteration used: 2097152 15 itteration used: 2097152 16 itteration used: 2097152 17 itteration used: 2097152 18 itteration used: 2097152 19 itteration used: 2097152 Last used: 2097152 Actual result: -------------- First used: 2097152 0 itteration used: 18874368 1 itteration used: 27262976 2 itteration used: 35651584 3 itteration used: 44040192 4 itteration used: 50331648 5 itteration used: 58720256 6 itteration used: 67108864 7 itteration used: 75497472 8 itteration used: 83886080 9 itteration used: 92274688 10 itteration used: 100663296 11 itteration used: 109051904 12 itteration used: 117440512 13 itteration used: 125829120 14 itteration used: 134217728 Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 36864 bytes) in E:\php_test\test.php on line 25 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=76488&edit=1

« previous php.bugs (#216392) next »