I ran into an odd problem while optimizing memory usage of Apache + PHP. Basically, the code explodes with the error message "Fatal error: the allowed memory size of 16777216 bytes has been exhausted (tried to allocate 50331646 bytes)" when trying to link the results of a MySQLi query.
Relevant tables:
CREATE TABLE `note` (
`noteID` int(11) NOT NULL AUTO_INCREMENT,
`contentID` int(11) NOT NULL,
`text` mediumtext NOT NULL,
PRIMARY KEY (`noteID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `content` (
`contentID` int(11) NOT NULL AUTO_INCREMENT,
`text` varchar(2048) NOT NULL,
`datestamp` datetime NOT NULL,
PRIMARY KEY (`contentID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
and the request that explodes is as follows:
select content.contentID,
content.text,
content.datestamp,
note.noteID,
note.contentID, note.text
from basereality.content as content
inner join basereality.note as note
on content.contentID = note.contentID
where content.contentID = 1028 ;
Query execution in MySQL on the server is normal, and the size of the returned "note" is under kilobytes.
, , 50331646, 0x2FFFFFE , . , PHP , , , .
- - , PHP?
btw , , , , .
( 50855936) ( 50331646 )
, , :
$statement->bind_result(
$content_contentID,
$content_text,
$content_datestamp,
$note_noteID,
$note_contentID,
$note_text);
, " " ", .
btw , . mediumtext :
select length(text) from basereality.note;
+
| length(text) |
+
| 938 |
| 141 |
| 1116 |
| 431 |
| 334 |
+