#32013 [Opn->Fbk]: MySQLi bind_result causes fatal error: memory limit reached
| From: | sniper@php.net | Date: | Fri, 25 Feb 2005 13:35:18 +0000 |
| Subject: | #32013 [Opn->Fbk]: MySQLi bind_result causes fatal error: memory limit reached | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-74571@lists.php.net to get a copy of this message | ||
ID: 32013
Updated by: sniper@php.net
Reported By: mhe at ltcgroup dot de
-Status: Open
+Status: Feedback
Bug Type: MySQLi related
Operating System: Debian Woody
PHP Version: 5.0.3
Assigned To: georg
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php5-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5-win32-latest.zip
Previous Comments:
------------------------------------------------------------------------
[2005-02-17 20:17:12] mhe at ltcgroup dot de
perhaps it is a mysql client lib issue, i downt know ..
php side: increasing memory limit isnt a solution
mysql side: alter table isnt a solution
------------------------------------------------------------------------
[2005-02-17 20:10:27] mhe at ltcgroup dot de
MEDIUMTEXT ~ 2^24 bytes = 16777216 bytes, which php tries to allocate
php dies, memory limit reached ..
mh, lets play with this. so what happens, if i use TEXT, which seems to
work ..
so i use memory_get_usage() befor and after ->bind_result($ID_ITEM)
before: 48120
after: 113848
dif: 65728
2^16+2 = 65538, which is the size of TEXT .. *ouch :-?
..
what happens, if i bind 2 variables to a TEXT ..
"select DESCRIPTION as DD, DESCRIPTION as DD2, from tt"
$stmt->bind_result($ID_ITEM, $IDD);
before: 48424
after: 179640
dif: (179640 - 48424) / 2 = 65608 ~ 2 * 2 ^16
! notice: table was empty
------------------------------------------------------------------------
[2005-02-17 19:32:12] mhe at ltcgroup dot de
Description:
------------
submit a prepared query to mysqli ext using method prepare().
if i use bind_result to bind a column to a variable php crashes with
fatal error: memory limit, if the column in database is mediumtext. if
you alter this to text, everything works fine.
using mysqld 4.1.10
--output: php5 -v
micronium:~/phpn# php5 -v
PHP 5.0.3-1.dotdeb.0 (cli) (built: Dec 16 2004 13:08:20)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.0.3, Copyright (c) 1998-2004 Zend Technologies
-- mysql:
CREATE TABLE tt (
ID_ITEM INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
TITLE VARCHAR(255) NULL,
DESCRIPTION MEDIUMTEXT NULL,
PRIMARY KEY(ID_ITEM)
);
-- php:
$query = "
select
DESCRIPTION
from
tt
";
$stmt = $db->prepare($query);
$stmt->execute();
$stmt->bind_result($DESCRIPTION); //-- this is line 63
-- output:
Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to
allocate 16777216 bytes) in /root/phpn/run.php on line 63
Allowed memory size of 8388608 bytes exhausted (tried to allocate 256
bytes)
-- mysql:
ALTER TABLE
tt CHANGE DESCRIPTION DESCRIPTION TEXT
-- php:
$query = "
select
DESCRIPTION
from
tt
";
$stmt = $db->prepare($query);
$stmt->execute();
$stmt->bind_result($ID_ITEM); //-- this is line 63
-- output:
::: everything is ok, no crahs, can go on
Reproduce code:
---------------
try to bind a MEDIUM text column to a variable, and php will crash ..
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=32013&edit=1