Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Tracking memory issues


Go to End


17 Posts   3965 Views

Avatar
Mo

Community Member, 541 Posts

26 September 2009 at 2:24am

Hi All,

I was wondering if anyone has any tips about tracking memory leaks/issues in Silverstripe?

I have a site that I have built, its working well except that it seems to use a load of memory. I have been moitoring the system performance on the server, and at one point the CPU usage from apache went over 75%.

It only seems to do it every so often though. But the trouble is that sometimes it is crashing the server!!

This site is the only one on the server as well.

Currently specs are:

Ubuntu server
Apache 2.2
PHP 5.2
SS 2.3.1

Any tips would be really usefull,

Cheers,

Mo

Avatar
dalesaurus

Community Member, 283 Posts

26 September 2009 at 4:02am

There are many ways to start peeking at the internals, here are a couple:

1. Enable the built in profiler with the ?debug_profile=1 ( More at http://doc.silverstripe.com/doku.php?id=profiler )

2. Use php's built in memory monitoring functions, starting with memory_get_usage(): http://us2.php.net/manual/en/function.memory-get-usage.php

3. If the first 2 don't suit you, try using PEAR::Benchmark: http://pear.php.net/package/Benchmark

4. Install xdebug and get your IDE setup with remote debugging so you can use some variant of cachegrind to REALLY get under the hood. With Ubuntu this is pretty trivial as it is in the repos: http://ubuntu-snippets.blogspot.com/2008/06/debugging-php-using-xdebug.html

Full Details on cachegrinding: http://www.ibm.com/developerworks/opensource/library/os-php-fastapps2/

Avatar
dalesaurus

Community Member, 283 Posts

26 September 2009 at 4:06am

One more point, if memory usage is an issue be try enabling a PHP accelerator like xcache or APC. It makes a dramatic difference.

http://en.wikipedia.org/wiki/List_of_PHP_accelerators

Avatar
Mo

Community Member, 541 Posts

26 September 2009 at 4:58am

Cool, that's pretty helpful. I will see how well I get on with the profiler first, as that requires the minimal amount of setup :)

Thanks,

Mo

Avatar
dhensby

Community Member, 253 Posts

26 September 2009 at 5:26am

?debug_memory=1 outputs the memory usage for outputting the page too!

Avatar
Mo

Community Member, 541 Posts

26 September 2009 at 7:58am

Oh wow, there all these options available that I didn't even know about... I wish I had known about that before this site went live, I wouldn't be where I am now :)

Avatar
bummzack

Community Member, 904 Posts

26 September 2009 at 9:07am

@Mo: You're not the only one who didn't knew about these.
Posts like this should be "stickied" :)

Avatar
dhensby

Community Member, 253 Posts

26 September 2009 at 10:52am

They are the little 'treats' you learn after using SS for a long time!

:D

Go to Top