I have moved my website to new server and got this problem,
on CDbCommand class, queryInternal method, $this->_statement=$this->getConnection()->getPdoInstance()->query($this->getText()); line(298), yii executes query SHOW CREATE TABLE table, and on pdo->query() there comes Allowed memory size of 16777216 bytes exhausted error. What can be wrong with that?
Well, this is a error from PHP. It tells you that the script you are trying to run needs more memory than you allow scripts to allocate on execution. So you have two options:
[list=1]
[*] increase the memory limit (somewhere in php.ini)
[*] or optimize your application so it uses less memory
I can’t tell you where the problem is located. But you could do a test and insert a
echo memory_get_usage();
before the call to the database class. I guess it will already be somewhere near that limit.
The show table query really shouldn’t be problematic, Post::model()->FindAll() is more likely to cause problems, especially if you have lots of posts (or very large ones) in your database.
And this happened after you moved the application? No other changes?
I just tried to recreate it, but without luck. Can you debug to this location and confirm it happens at first invocation of "SHOW CREATE TABLE table" to ensure it isn’t a problem with an infinite loop and endless calls to findAll()? By the way: The statement isn’t "SHOW CREATE TABLE table" literally, is it?
If it is really a problem that occurs during the first call of this statement, can you reproduce the error with a plain php script that doesn’t use yii (only create pdo object and run query)?
You can also enable db profiling in the config, maybe that tells you more:
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
/* Log everything right into the browser (for development) */
array(
'class'=>'CWebLogRoute',
'levels'=>'error, warning, profile, info, trace',
),
/* Log everything right into the browser (for development) */
array(
'class'=>'CProfileLogRoute',
'report'=>'summary', /* summary or callstack */
),
),
),
'db'=>array(
'class'=>'CDbConnection',
'connectionString'=>'...',
'username'=>'...',
'password'=>'*****',
'charset'=>'UTF8',
'emulatePrepare'=>true,
'enableProfiling'=>true,
),
I once had the problem of this happening when the my application threw an error and then a customer error handler was invoked which that used debug_backtrace. It seems like debug_backtrace sometimes uses up a huge amount of memory.
No i haven’t, because it crashed also. I think, because I have had a problem with ~CDbMessage table names (incorrect cases). Real error was catched on catch() section whitch i have missed, and framework were trying to show me error message, but with incorrect table names in multilanguage calsses it crashed with out of memory error…