On 04/10/2009, at 7:27 PM, Markus Krötzsch wrote:
== How to do memory profiling? ==
I tried to enable PHP memory profiling in xdebug, but all I got was time data, and I gave up on this for now. The aggregated outputs in profileinfo.php were not very useful for me either; in particular, I think that they do not take garbage collection into account, i.e. they only show new memory allocations, but not the freeing of old memory. So one piece of code may allocate 20M but never need more than 4M at a time, while another consumes the same amount and keeps it due to some mem leak. Especially, the sums and percentages do apparently not show the real impact that a piece of code has on using PHP's memory.
So I based my memory estimations on the minimal PHP memory limit that would not return a blank page when creating a page preview (ini_set('memory_limit',...);). This measure is rather coarse for debugging, but it might be the one number that matters most to the user. The results were reproducible.
For future reference, you can use the memory_get_usage function: http://php.net/manual-lookup.php?pattern=get+memory+usage&lang=en
-- Andrew Garrett agarrett@wikimedia.org http://werdn.us/