|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2013-03-25 14:09 UTC] psiek at mscgva dot ch
Description: ------------ Hi, Each time I use dblib + freetds (read or write) I got following messages : [Mon Mar 25 08:53:55 2013] [error] [client x.x.x.x] PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 140429927214120 bytes) in Unknown on line 0, referer: http://blahblah All seems to work, excepted the weird message that fill my logs. I tryed with multiple versions of php (from 5.4.0 up to 5.4.11) on three different servers, they all give the same message. Regards, Expected result: ---------------- No error message in error/php log Actual result: -------------- [Mon Mar 25 08:53:55 2013] [error] [client x.x.x.x] PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 140429927214120 bytes) in Unknown on line 0, referer: http://blahblah PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 14:00:01 2025 UTC |
Hi, Thanks for your reply. Here is a sample code that reproduce the error. Please note that sometimes this code not generate the error, and I can't find why. When you reload the page, it mostly generated but a few time not. <?php $connection = new PDO('dblib:dbname=xxx;host=yyy;', 'zxzxzx', 'zxzxzx'); $connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $query = $connection->query("xxx.dbo.zzzzz @ServerName = NULL, @ProcessName = NULL, @LayoutID = NULL"); $RecordsetFields = array(); do { $rowset = $query->fetchAll(PDO::FETCH_ASSOC); if ($rowset) { $RecordsetFields[] = $rowset; } } while ($query->nextRowset()); print_r($RecordsetFields); The query is working perfectly, excepted the message in error.log. This is anoyong because we are monitoring errors in real time and this is generating 99% of false positives. Once again, thanks for your help. Regards,[Mon Mar 25 08:53:55 2013] [error] [client x.x.x.x] PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 140429927214120 bytes) in Unknown on line 0, referer: This log indicates that you have been exhausted available memory. (512MB) When you get query result from your db server, records are stored in memory which is not managed by PHP. If you do do { $rowset = $query->fetchAll(PDO::FETCH_ASSOC); if ($rowset) { $RecordsetFields[] = $rowset; } } while ($query->nextRowset()); Then results are stored in PHP managed memory. I wander why your script works(?) even with the memory exhaustion error. Are you sure that query result fit in your PHP managed memory? How many records are there? and what the size of each record? Could you use memory_get_usage() http://jp2.php.net/manual/en/function.memory-get-usage.php in the "do" loop to see memory usage of your script and report the result back?I have same problem :( PHP 5.5.9-1ubuntu4.3 (cli) (built: Jul 7 2014 16:36:58) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick RethansI'm getting the same result in my log files for a wordpress site, but I haven't yet determined what statement is causing it. Here's my PHP info: PHP 5.5.9-1ubuntu4.4 (cli) (built: Sep 4 2014 06:56:34) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies$rowset = $query->fetchAll(PDO::FETCH_ASSOC); This will cache the entire recordset in memory. The pdo dblib driver was updated way back to specifcally allow iteration through a very large recordset (e.g. while($row=$query->fetch()) {} ) without memory exhaustion, However by calling fetchAll() there is no optimization that can be done. How many rows with how many bytes each are you fetching from the server? Are there varbinary, text or image fields involved? Those can be quite large.