I mapped a Post object with Doctrine to the wp_posts
table used by WordPress. A column called post_content
in this table is a LONGTEXT
that can contains 4GB.
When I try to load the objects from these table, I receive the following message:
Fatal error: Allowed memory size of 268435456 bytes exhausted (tried
to allocate 4294967296 bytes) in
/home/rdinhani/renato/php-lib/DoctrineORM-2.2.2/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php on line 165
This occurs when executing a query to load the objects (at the moment, only ONE row will be returned).
So, Doctrine is trying to allocate 4GB to load the value inside this column, but this overflow the memory. I don’t have large values inside this column, only a few texts.
There is some configuration in Doctrine or PHP that can avoid it to try to allocate the 4GB to the column, or maybe, set the maximum limit in MySQL column to a smaller value like 2MB, 10MB, etc?
Mysqli driver has a bug.
When try to select mediumtext or longtext field it tries to allocate the whole field size 2^32 bytes = 4294967296.
Solution: Change to PDO_Mysql or change the medium/longtext field to text field.