Re: How to measure memory leakage/usage in PHP?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux