Bug #76488 [NEW]: Memory leak when fetching a BLOB field
| From: | sim-mail at list dot ru | Date: | Sun, 17 Jun 2018 13:17:08 +0000 |
| Subject: | Bug #76488 [NEW]: Memory leak when fetching a BLOB field | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-215762@lists.php.net to get a copy of this message | ||
From: sim-mail at list dot ru
Operating system: Any OS
PHP version: 7.2.6
Package: PDO Firebird
Bug Type: Bug
Bug description:Memory leak when fetching a BLOB field
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 bug report at https://bugs.php.net/bug.php?id=76488&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76488&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76488&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76488&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=76488&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=76488&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=76488&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=76488&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=76488&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=76488&r=support
Expected behavior: https://bugs.php.net/fix.php?id=76488&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=76488&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=76488&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=76488&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76488&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=76488&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=76488&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=76488&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=76488&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=76488&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=76488&r=mysqlcfg