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

From: Date: Thu, 06 Mar 2008 04:19:00 +0000
Subject: Re: How to measure memory leakage/usage in PHP?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-271062@lists.php.net to get a copy of this message
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/

« previous php.general (#271062) next »