Bug #81059 [NEW]: Memory leaks PDO MySQL reading blob field
From: andresr dot alz at gmail dot com
Operating system: Docker FROM php:8.0.6-cli
PHP version: 8.0.6
Package: PDO MySQL
Bug Type: Bug
Bug description:Memory leaks PDO MySQL reading blob field
Description:
------------
#### Dockerfile
FROM php:8.0.6-cli
RUN docker-php-ext-install pdo_mysql
RUN docker-php-ext-enable pdo_mysql
COPY . /usr/src/myapp
WORKDIR /usr/src/myapp
ENTRYPOINT ["php", "testing_pdo.php"]
####
This is not happening with php < 7.3
Test script:
---------------
// testing_pdo.php
<?php
ini_set('memory_limit', '-1');
function _get_connection()
{
print "\nget_connection";
$opt = array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
);
try {
$dbconn = new PDO(
"mysql:host=" . "localhost",
"user",
"user_test",
$opt
);
$dbconn->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);
return $dbconn;
} catch (PDOException $e) {
print "Error: $e";
return null;
}
}
function _big_query($dbconn)
{
print "\nbig query running ...";
$CSV_results = "";
$sql = "SELECT sent_blob from test WHERE id = 1";
$stm = $dbconn->prepare($sql);
$stm->execute();
$stm->bindColumn(1, $CSV_results, PDO::PARAM_LOB);
$stm->fetch(PDO::FETCH_BOUND);
$stm->closeCursor();
return $CSV_results;
}
print "\nStarting ....";
$conn = _get_connection();
if ($conn != null) {
$result = _big_query($conn);
print $result;
}
Expected result:
----------------
Memory on docker container keeps almost the same than network IO
Actual result:
--------------
Memory is increasing in a weird way
--
Edit bug report at https://bugs.php.net/bug.php?id=81059&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=81059&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=81059&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=81059&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=81059&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=81059&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=81059&r=support
Expected behavior: https://bugs.php.net/fix.php?id=81059&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=81059&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=81059&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=81059&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81059&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=81059&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=81059&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=81059&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=81059&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=81059&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=81059&r=mysqlcfg
Thread (7 messages)
- andresr dot alz at gmail dot com