atom feed7 messages in net.php.lists.php-generalRe: [PHP] How to measure memory leaka...
FromSent OnAttachments
Zareef AhmedMar 5, 2008 7:57 pm 
ChrisMar 5, 2008 8:18 pm 
Zareef AhmedMar 5, 2008 8:38 pm 
ChrisMar 5, 2008 8:43 pm 
Zareef AhmedMar 5, 2008 9:10 pm 
Frank ArensmeierMar 5, 2008 11:51 pm 
Richard LynchMar 7, 2008 7:04 am 
Subject:Re: [PHP] How to measure memory leakage/usage in PHP?
From:Zareef Ahmed (zar@zareef.net)
Date:Mar 5, 2008 8:38:20 pm
List:net.php.lists.php-general

Hi Chris,

Thanks for such quick response.

quite good suggestion, but my application is using a framework and lots of includes and even autoloads of classes are being done, so using break point approach is not possible for me.

Well, trying to do something so I can call my memory usage function after certain number of lines or predefined life time of php script, any suggestion?

Thanks and Regards Zareef Ahmed

On 3/6/08, Chris <dmag@gmail.com> wrote:

Zareef Ahmed wrote:

Hi All,

I am looking into the concepts behind memory management in PHP. Which kind of approach will be best to measure memory leakage or usage in a PHP script?

I can measure my apache process but is there any way by which I can know which exact part of script is consuming how much memory?

Start off with putting something like this:

error_log('in file ' . __FILE__ . ' at line ' . __LINE__ . ' memory usage is ' . memory_get_usage(true) . "\n", 3, '/path/to/log.file');

every 100 lines and work out where your spikes are.

When you're looking at a section that jumps a lot, put it every 10 lines - work out which parts are causing the big jumps and go from there.

Or use xdebug profiling to work out which parts of your app are being used the most and start there - http://xdebug.org/docs/profiler