Yii App Reaches Memory Limit On Linux Server

Hello! I have a really strange problem and I dont know how to solve it. My application reaches memory limit from time to time and Internal server error 500 happens. I have limit of 570MB on shared hosting. I tried to debug my application and YiiDebug Toolbar shows that every page is consuming about 10-12MB of memory. I dont really get where is the problem. On my local wamp server, there are no problems.

Can anyone help me? At least tell me where to start looking for memory leaks because I dont see any obvious.

Here is capture of memory resource usage in cPanel:


Try to set ‘YII_DEBUG’ to false (in index.php) or comment the line.

I already commented that line :confused:

hum, that was what I’ve seen here as a solution for the same kind of problems …

does this happens on some particular request (<=> some havy sql request) or is it unpredictable ?

It is unpredictable. That’s why is strange to me…

well, I’m sorry, but I’m unable to help you more :(

Thanks anyway. Anyone else?

I have read somewhere that the problem might be in lot of AR records. I don’t really know how much is too much.

On frontpage I have CGridView with 3 pages (DataProvider is from AR). i have 4 more pages, all of them get data from AR. 3 of them have about 20-30 records and one have 50-60 records. Is that lot of AR records?

My site is not really crowded so I don’t think that lot of users is a problem. It is a small intranet for one association.

Installation you describe shouldn’t cause memory problems AFAK.

Can you provide full error stack?

In my practice this problem was always caused by one reason - error in code that leads to endless operation.

Totally agree :rolleyes:

Hm… You mean error log from cPanel? The only error that is logged whenever app reaches memory limit is this:

(12)Cannot allocate memory: couldn’t create child process: /opt/suphp/sbin/suphp for /home/xxx/public_html/index.php + some referer

I have put a function inside every action in every controller to see how much memory each action uses, and the results are 7MB average.

Well, I hoped yii error stack is available.

I googled a bit and found out there’re quite a lot of same error messages with some ideas what to do and where to dig. I think it’s a good idea to investigate these cases first and to try to catch more information on the error, giving attention to what the error says:


couldn't create child process: /opt/suphp/sbin/suphp


Sorry, that’s all I can suggest for now ).

thanks for all the information guys

Hi vladotg

  1. set debug_mode to false

  2. use Yiilite rather run yii on index.php

  3. do you use any cache mechanism in yii?

  4. Is database on localhost same with database on server (both schema and records)?

  5. Did you check any server issues?

  1. I already did that.

  2. I’ll try that. But what are the differences between yiilite and yii?

  3. No, i don’t use any cache mechanism.

  4. Yes, it is the same database.

  5. I have checked, the hosting company says that they think the problem is in application.

yiilite is more lighter than yii combined with debug mode=false

Did you check the protected/runtime/application.log for relative errors?

Hm… I just saw something interesting in application.log. There are some errors that are saying:

[error] [exception.CHttpException.404] exception ‘CHttpException’ with message ‘The system is unable to find the requested action “cache”.’ in /home/xxx/yii/framework/web/CController.php:484

Can that be related?

check in protected/config/main.php for setting of cache, may be you have set no-existance cache

This is the setting:




comment entire cache on main.php to check, delete the application.log end request again, see if application.log trace any other problem