From: cduncan at regatta dot com Operating system: Linux PHP version: 5.5.4 Package: MySQLi related Bug Type: Bug Bug description:High memory usage from mysqli:query()
Description: ------------ When executing a query that returns a large number of rows (around 16 million) the query() function appears to use a lot more memory than it did in version 5.3.8 I looked through the changelogs and couldn't find any obvious reason why, or any mention of a change in how the function works Test script: --------------- <?php $sql = new mysqli("localhost","username","password"); function checkMemory($key="") { $memory = round(memory_get_usage(true) / 1024 / 1024) . "mb"; echo "Memory " . $key . ": " . $memory . "\n"; } checkMemory("Before"); $query = "SELECT field1a, field2a, valb1, valb2, valb3, valb4 FROM test.table1 JOIN test.table2 ON companyb=companya AND field1b=field1a WHERE companya='TEST'"; $result = $sql->query($query); checkMemory("After"); $field = $result->fetch_field(); echo "End\n"; Expected result: ---------------- user@server:~$ /usr/local/php-5.3.8/bin/php memory.php Memory Before: 1mb Memory After: 1mb End Actual result: -------------- user@server:~$ /usr/local/php-5.5.4/bin/php memory.php Memory Before: 0mb Memory After: 427mb PHP Fatal error: Out of memory (allocated 1603796992) (tried to allocate 20 bytes) in /home/user/memory.php on line 17 -- Edit bug report at https://bugs.php.net/bug.php?id=65741&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=65741&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=65741&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=65741&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=65741&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=65741&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=65741&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=65741&r=needscript Try newer version: https://bugs.php.net/fix.php?id=65741&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=65741&r=support Expected behavior: https://bugs.php.net/fix.php?id=65741&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=65741&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=65741&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=65741&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65741&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=65741&r=dst IIS Stability: https://bugs.php.net/fix.php?id=65741&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=65741&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=65741&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=65741&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=65741&r=mysqlcfg