I’ve got a small application that works fine on a dataset of around 50 accounts. But as the number of accounts is increased, the memory usage increases to 64 KB. But I know the data involved in my controller/view cannot be using more than 5 KB, tops.
I see the memory usage issue in both Firefox and MSIE; haven’t tested other browsers.
I see the memory usage issue in ALL my controllers, not just the more complex ones. For instance, the problem occurs when the controller simply grabs ONE active record, representing the customer’s account, and then displays a contact form.
Again, when I had fewer accounts, pages did seem rather slow to load, but now we’re talking 76 seconds.
This instance of my code is running with YII_DEBUG on, and I’m also running logging. I understand that both of these things have an impact on Yii’s performance. I tried removing both of them, but page loads still take 76 seconds, with 64KB memory usage; so I turned YII_DEBUG back on and also am using logging.
My main question is: how do I PINPOINT where the memory usage is spiking?
To figure out what’s been going on, I modified the main index.php file with these:
ini_set('memory_limit','256M');
set_time_limit(0);
I also modified my php.ini:
memory_limit = 256M
Then, in my config file, I turned on CProfileLogRoute, and I am using it to figure out how long various code blocks take.
I profile 2 things in the action function for my controller:
-
How long it takes to fetch from the database. I call this block "setup".
-
How long it takes to render my view. I call this profile block "render".
The setup is taking on average 0.5 seconds
The call to render() is taking on average 76 seconds
I tried 2 things, unsuccessfully, to decrease the time and memory usage:
-
I made my view entirely empty. Didn’t help
-
In the call to render(), I passed in NO arguments to the view (since the
view is empty, and doesn’t need any variables.) Didn’t help
So, I’m left wondering how to pinpoint WHERE the memory usage is spiking. I expected it to be with the setup code, because that’s where I access two CActiveRecord instances. It wasn’t there. It’s in the render() code. But render() is mighty complex. It’s not so helpful to know that render() is the culprit, because render() calls so many other functions.
Can anyone offer advice on how to easily figure out where exactly this memory allocation is taking place?
Happy to provide more information if needed, and very grateful for any pointers!