Long time back I also having the same problem,but I contacted the In Motion technical support team and solved my problem
Long time back I also having the same problem,but I contacted the In Motion technical support team and solved my problem
Memory limit errors in PHP are tricky to troubleshoot, remember that the OS and service(apache) may impose their own limits on PHP - like someone said earlier, try to set the memory limit in apache if the error returns, and for future reference
I’m experiencing the same problem here on my development system (windows 7, zend server 5.6, php 5.3 and memory_limit 128M)
I think something is wrong with the Yii framework (probably Menu widget?) because I’ve never had this error before using Yii
has anybody figured out how to fix this error without extending the memory limit?
128M is a ton of memory for Yii. Typical website uses no more than 8—9 MB per page run. Can be a bit more if AR is used heavily. CMenu was used in production projects by many-many people so there shouldn’t be any issue with it.
Either you have some server misconfiguration or using AR without limit with huge amount of data.
exactly, 128M is a lot of memory for a single user development machine. that’s actually what makes me nervous using Yii in a production server!
I don’t use ARs at all. last time I had this error was on a simple page with a static view (just printing an html form) and a couple of CMenu widgets. passing different values to the CMenu widgets raised some memory errors
the confusing part is that the error is not always persistent and reloading the webpage sometimes makes the error go away!
I think if this was a server misconfiguration I would have the error in my other projects too. I’m not much of a server admin though so if there’s any (mis)configuration capable of raising this error I would appreciate it if you point me into the right direction
Can you create a simple application that produces this error in your environment so you’ll send it to us and we’ll be able to try reproducing it?
Or you are surely editing the wrong PHP.INI file
Sometimes there are 2 ini files:
/etc/php5/apache2/php.ini
/etc/php5/cli/php.ini
I am just in the process of memory optimization in my very large application (each request can return more than 40mb of XML), and I can say that for a normal Yii application, each request should not use more than 15MB.
My application was using 100MB per request, now optmized it uses ~25MB.
These things helped immenselly:
Removing ioncube from Yii, and using APC: ioncube doubles the memory usage, and APC doesn’t work with it. APC alone on Yii lowered the memory about 30%;
Don’t use AR when too many record, like exporting XML. Making the queries by hand, the performance increased more that 30%, and memory usage lowered by 20%;
Use a newer PHP version. Old PHP versions have many memory leaks.
I did a large study of Yii memory usage, I can say for sure that the problem isn’t with Yii.
I haven’t been able to reproduce this error so far. all I get is random fatal errors which will be gone by refreshing the page!
this is the latest error message I got, trying to write a new module:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 541975884 bytes) in D:\WebServer\hosts\localhost\yii-1.1.10.r3566\framework\YiiBase.php on line 418
as you can see the script tries to allocate more than 516 MB while the memory limit is 128MB
Anything special in this module? Is it processing huge amount of data? Using non-standard PHP extensions? Reading huge files? Doing recursive calls?
the module wasn’t anything special. just a contact form with a few simple pages.
the error occurred the first time I clicked the contact form’s link to open the module, pointing to the YiiBase::autoload method and it didn’t happen again after reloading the webpage
so i thought maybe something was wrong with my server’s cache! now I reinstalled the zend server, disabled all the extra extensions, and reduced the memory_limit to 32MB hoping the error occurs more often and I can debug it
no errors since then yet
I know this thread is a few months old now but I just experienced this as well on my local dev and thought I should share my findings.
After adding the following code to one of my models
private $filetmp_path='protected/artworkImages/tmp/';
private $file_path='protected/artworkImages/';
public function __construct()
{
parent::__construct();
$this->filetmp_path = $this->filetmp_path . date('Y-m');
$this->file_path = $this->file_path . date('Y-m');
}
I started getting the following error
Fatal error: Allowed memory size of 131072000 bytes exhausted (tried to allocate 523800 bytes) in /var/www/someproject/protected/models/Artwork.php on line 378
It’s interesting that there isn’t 378 lines in the file so I don’t know what to make of it. Simply removing the construct removes the problem.
change from __construct() to init()
[color="#006400"]/* Moved from Bugs to General Discussion */[/color]
I have had similar issues in the past, and they were all due to valid requirements. Adjusting the memory limits in PHP worked well.
I am now presented with a new scenario, where I am producing dynamically a large output (sitemap xml file), which exceeds any reasonable memory limit I would ever set in PHP.
The question here is how to get around Yii’s output rendering and buffering mechanisms so that I can just flush the content out rather than keeping it in memory?
Hi
To get around the buffering, I suppose that emptying the output buffers is sufficient (as now done in the EExcelView extension):
/**
* Performs cleaning on mutliple levels.
*
* From le_top @ yiiframework.com
*
*/
private static function cleanOutput()
{
for($level=ob_get_level();$level>0;--$level)
{
@ob_end_clean();
}
}
Yii logger leaks memory. My console application was performing a loop of a couple of millions AR requests. Logger was consuming all my memory. Disabling it solved the issue.
If you were logging the AR requests, then the logger was keeping all those messages in memory because they are dumped at the end of the application. If it is that, it is not a o leak. It could be a memory leak if the logger would be allocating memory and not free it when it does not need this memory anymore.
I did not log anything in my console application. I just saved some AR’s.
I had this error on YII2 when I tried to run my project in debug mode on production server. I just commented out specified lines, as it described in index.php:
// comment out the following two lines when deployed to production
//defined('YII_DEBUG') or define('YII_DEBUG', true);
//defined('YII_ENV') or define('YII_ENV', 'dev');