|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-11-29 00:25 UTC] amex at bucksvsbytes dot com
Description:
------------
In PHP 5.3.10 and PostgreSQL 9.1, when executing PDOStatement::fetchAll(), if the retrieved data busts the PHP memory limit, the script dies quietly, without throwing an "out of memory" error.
Test script:
---------------
//ini_set('memory_limit','256M');
$dsn=;//appropriate Data Source Name string
$sql=;//any query that returns slightly more data than the PHP memory limit allows (default limit is 128 MB on my server)
$db=new PDO($dsn);
$result=$db->query($sql);
$datarray=$result->fetchAll();//fetch all rows into an array
Expected result:
----------------
When fetchAll() retrieves too much data, the script dies quietly, instead of throwing an "out of memory" error.
When I uncomment the first line, the script runs to completion, thus proving that the quiet death was due to lack of memory.
The problem seems to relate to the postgresql driver, as the same thing happens when I use pg_connect/pg_query/pg_fetch_all instead of PDO to get data from the same query.
This is the only PHP "out of memory" condition I've ever seen where no error is thrown.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 02:00:01 2025 UTC |
Cannot reproduce. This is probably your kernel OOM killer tricking you. cli -d error_reporting=-1 -d memory_limit=5M -r '$pdo = new PDO("pgsql:user=phptest dbname=phptest"); $stm = $pdo->query("select repeat(\x27a\x27, 5*1024*1025) as data"); var_dump($stm->fetchAll());' Fatal error: Allowed memory size of 5242880 bytes exhausted at /home/mike/src/php-5.4/ext/pdo/pdo_stmt.c:641 (tried to allocate 5248001 bytes) in Command line code on line 1