|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits              [2009-05-21 11:36 UTC] ninzya at inbox dot lv
  [2009-05-21 13:02 UTC] mikec at mikenz dot geek dot nz
  [2009-05-24 18:08 UTC] johannes@php.net
  [2010-03-16 23:59 UTC] rick at igabe dot us
  [2013-05-15 12:00 UTC] m4t1k at interia dot pl
 | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Wed Oct 22 16:00:01 2025 UTC | 
Description: ------------ A simple loop fetching rows from a database uses a lot more memory of php5.3 when compared to php5.2. First noticed on a Debian machine. Confirmed on a Windows machine with latest snaps (20-May-2009). php.ini based on php.ini-dist/development only change is to enable mysqli. Reproduce code: --------------- <?php /** Mysql test table: CREATE TABLE `test` ( `id` int(11) NOT NULL auto_increment, `value` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; INSERT INTO `test` VALUES (1, 910044366),(2, 598209383),(3, 1057704306),(4, 877739287),(5, 260395243),(6, 1154353180),(7, 19390630),(8, 362285832),(9, 510459913),(10, 222644712),(11, 824641253),(12, 969677378),(13, 1131665776),(14, 263701992),(15, 409107462); */ $before = memory_get_usage(); echo "Memory Usage (in bytes)"; echo "\nBefore: " . $before; $db = new mysqli("127.0.0.1", "test", "testpasswd", "test"); $result = $db->query('SELECT * FROM `test`'); $rows = 0; while($result->fetch_array(MYSQLI_ASSOC)) {$rows++;} $after = memory_get_usage(); echo "\nAfter: " . $after; echo "\nDelta: " . ($after - $before); echo "\nDelta per row: " . round(($after - $before)/$rows) . ' bytes per row'; Expected result: ---------------- C:\test\php-5.2-nts-win32-VC6-x86-latest>php -v PHP 5.2.10-dev (cli) (built: May 19 2009 11:46:39) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies C:\test\php-5.2-nts-win32-VC6-x86-latest>php r:\dbmem.php Memory Usage (in bytes) Before: 55216 After: 56080 Delta: 864 Delta per row: 58 bytes per row Actual result: -------------- C:\test\php-5.3-nts-win32-VC9-x86-latest>php -v PHP 5.3.0RC3-dev (cli) (built: May 19 2009 12:57:00) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies C:\test\php-5.3-nts-win32-VC9-x86-latest>php r:\dbmem.php Memory Usage (in bytes) Before: 321328 After: 337384 Delta: 16056 Delta per row: 1070 bytes per row Would expect the Delta per row to be the similar for PHP 5.3 but this is no where near.