Bug #80761 [NEW]: PDO uses too much memory

From: Date: Wed, 17 Feb 2021 09:30:59 +0000
Subject: Bug #80761 [NEW]: PDO uses too much memory
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-232219@lists.php.net to get a copy of this message
From: anton at 4blk dot com Operating system: Ubuntu 16.04 PHP version: 7.3.27 Package: PDO MySQL Bug Type: Bug Bug description:PDO uses too much memory Description: ------------ Fetching long strings or BLOBs from MySQL uses too much memory. Creating 100 MB string in php uses ~100 MB memory. Fetching 100 MB string from database uses ~600 MB memory. Test script: --------------- <?php // docker run --net=host --name db -e MYSQL_ALLOW_EMPTY_PASSWORD=yes -d mysql:5 --max_allowed_packet=256M ini_set('memory_limit', -1); $mb = 1024**2; $n = 100 * $mb; // $x = str_repeat('a', $n); $db = new pdo('mysql:host=127.0.0.1;port=3306', 'root', '', [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]); $x = $db->query("select repeat('a', $n)"); printf("%.2F\n", memory_get_peak_usage() / $mb); Expected result: ---------------- ~100 MB Actual result: -------------- ~600 MB -- Edit bug report at https://bugs.php.net/bug.php?id=80761&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=80761&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=80761&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=80761&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=80761&r=needscript Try newer version: https://bugs.php.net/fix.php?id=80761&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=80761&r=support Expected behavior: https://bugs.php.net/fix.php?id=80761&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=80761&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=80761&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=80761&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=80761&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=80761&r=dst IIS Stability: https://bugs.php.net/fix.php?id=80761&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=80761&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=80761&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=80761&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=80761&r=mysqlcfg

« previous php.bugs (#232219) next »