22977 Posts in 11742 Topics by 2826 members
|Go to End||Next >|
26 September 2009 at 2:24am
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:
Any tips would be really usefull,
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/
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.
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
26 September 2009 at 5:26am
?debug_memory=1 outputs the memory usage for outputting the page too!
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
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"
26 September 2009 at 10:52am
They are the little 'treats' you learn after using SS for a long time!
|Go to Top||Next >|