Actionsee
Actionsee

Reputation: 107

Memory size exhausted while trying to use MySQLi

I am using MysqliDb Class from there.

https://github.com/ajillion/PHP-MySQLi-Database-Class/blob/master/MysqliDb.php

When i used on local pc, i don't have any problem. But I bought host yesterday. And I uploaded my files about 5 min ago and doesn't work. I checked my host and created error_log file and this..

PHP Fatal error:  Allowed memory size of 75497472 bytes exhausted (tried to allocate 4294967296 bytes) in /home/(..)/MysqliDb.php on line 417

What is this problem?

I used this code on my config file. But same didn't work.

ini_set('memory_limit', '192M');

Upvotes: 1

Views: 3174

Answers (2)

sectus
sectus

Reputation: 15464

I think that is that you are using LongText in your database.

Please read this message: https://bugs.php.net/bug.php?id=51386

So try to mysqli::store_result before bind_result.

Upvotes: 3

Sergi Juanola
Sergi Juanola

Reputation: 6647

ini_set commands that affect the limits of the server tend to be blocked (so, you may only be able to use the ones related to showing errors or so).

Bear in mind that you are trying to allocate 4.2 Gb, which is a fairly big amount of information for a website.

Recommendations:

  • Check if you are creating an infinite loop which tries to load that big bunch of information (not only in that class, but prior to that call in your own code).
  • Use a lighter mysqli class (did you try the one that comes by default with PHP 5)?
  • Check if your problem can be solved in another (maybe asynchronous? that amount of memory is insane for a website), lighter way, probably with another language like C or C++ to release the load out of Apache.
  • Talk to your hosting provider and try to convince them to let you load 4.2 Gb of data.

Upvotes: -1

Related Questions