Yii App Reaches Memory Limit On Linux Server


(Vladorosancic) #1

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:


(Luc Pfister) #2

Hi,

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


(Vladorosancic) #3

I already commented that line :confused:


(Luc Pfister) #4

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 ?


(Vladorosancic) #5

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


(Luc Pfister) #6

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


(Vladorosancic) #7

Thanks anyway. Anyone else?


(Vladorosancic) #8

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.


(Yugenekr) #9

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.


(Wilnis) #10

Totally agree :rolleyes:


(Vladorosancic) #11

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.


(Yugenekr) #12

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:

[size="2"][color="#1c2837"]


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

[/color][/size]

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


(Doltuku1) #13

thanks for all the information guys


(Konapaz) #14

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?


(Vladorosancic) #15
  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.


(Konapaz) #16

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

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


(Vladorosancic) #17

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?


(Konapaz) #18

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


(Vladorosancic) #19

This is the setting:

‘cache’=>array(

       'class'=&gt;'CFileCache',                    


  ),

(Konapaz) #20

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