<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Log memory usage using declare and ticks in PHP</title>
	<atom:link href="http://www.davedevelopment.co.uk/2008/05/12/log-memory-usage-using-declare-and-ticks-in-php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.davedevelopment.co.uk/2008/05/12/log-memory-usage-using-declare-and-ticks-in-php/</link>
	<description>Dave Marshall</description>
	<lastBuildDate>Sun, 24 Jan 2010 23:46:01 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Online Money Making</title>
		<link>http://www.davedevelopment.co.uk/2008/05/12/log-memory-usage-using-declare-and-ticks-in-php/comment-page-1/#comment-87760</link>
		<dc:creator>Online Money Making</dc:creator>
		<pubDate>Wed, 02 Sep 2009 02:55:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.davedevelopment.co.uk/?p=59#comment-87760</guid>
		<description>Nice work on that one Mathieu!</description>
		<content:encoded><![CDATA[<p>Nice work on that one Mathieu!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Oliver Nassar</title>
		<link>http://www.davedevelopment.co.uk/2008/05/12/log-memory-usage-using-declare-and-ticks-in-php/comment-page-1/#comment-83708</link>
		<dc:creator>Oliver Nassar</dc:creator>
		<pubDate>Tue, 16 Jun 2009 21:37:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.davedevelopment.co.uk/?p=59#comment-83708</guid>
		<description>Check out: http://particletree.com/features/php-quick-profiler/
Should meet most of the needs discussed in this post.</description>
		<content:encoded><![CDATA[<p>Check out: <a href="http://particletree.com/features/php-quick-profiler/" rel="nofollow">http://particletree.com/features/php-quick-profiler/</a><br />
Should meet most of the needs discussed in this post.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Splitice</title>
		<link>http://www.davedevelopment.co.uk/2008/05/12/log-memory-usage-using-declare-and-ticks-in-php/comment-page-1/#comment-79651</link>
		<dc:creator>Splitice</dc:creator>
		<pubDate>Sun, 19 Apr 2009 23:25:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.davedevelopment.co.uk/?p=59#comment-79651</guid>
		<description>You could always load into a shm or var cache like XCache</description>
		<content:encoded><![CDATA[<p>You could always load into a shm or var cache like XCache</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris</title>
		<link>http://www.davedevelopment.co.uk/2008/05/12/log-memory-usage-using-declare-and-ticks-in-php/comment-page-1/#comment-52732</link>
		<dc:creator>Chris</dc:creator>
		<pubDate>Mon, 26 May 2008 01:02:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.davedevelopment.co.uk/?p=59#comment-52732</guid>
		<description>Hi Dave,

My example was to show that if you keep the memory usage in an array (which is stored *in memory*) - you get wrong results.</description>
		<content:encoded><![CDATA[<p>Hi Dave,</p>
<p>My example was to show that if you keep the memory usage in an array (which is stored *in memory*) &#8211; you get wrong results.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: daveyboy</title>
		<link>http://www.davedevelopment.co.uk/2008/05/12/log-memory-usage-using-declare-and-ticks-in-php/comment-page-1/#comment-52091</link>
		<dc:creator>daveyboy</dc:creator>
		<pubDate>Tue, 20 May 2008 07:34:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.davedevelopment.co.uk/?p=59#comment-52091</guid>
		<description>@Chris - Not really sure I follow you&#039;re example. I agree logging to a file would be better for accuracy, but would slow your application down greatly, hence the &#039;insert your logging code here&#039;.</description>
		<content:encoded><![CDATA[<p>@Chris &#8211; Not really sure I follow you&#8217;re example. I agree logging to a file would be better for accuracy, but would slow your application down greatly, hence the &#8216;insert your logging code here&#8217;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris</title>
		<link>http://www.davedevelopment.co.uk/2008/05/12/log-memory-usage-using-declare-and-ticks-in-php/comment-page-1/#comment-52074</link>
		<dc:creator>Chris</dc:creator>
		<pubDate>Tue, 20 May 2008 03:45:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.davedevelopment.co.uk/?p=59#comment-52074</guid>
		<description>You&#039;re better off logging the backtrace etc to a file, otherwise you are using a global variable which takes up memory itself.


&lt;?php

echo &quot;at line &quot; . __LINE__ . &quot; memory is &quot; . memory_get_usage(true) . &quot;\n&quot;;

$log = array();
for ($i = 0; $i  microtime(true),
			&#039;memory&#039; =&gt; memory_get_usage(true),
			&#039;file&#039; =&gt; __FILE__
		);
}

echo &quot;at line &quot; . __LINE__ . &quot; memory is &quot; . memory_get_usage(true) . &quot;\n&quot;;</description>
		<content:encoded><![CDATA[<p>You&#8217;re better off logging the backtrace etc to a file, otherwise you are using a global variable which takes up memory itself.</p>
<p>&lt;?php</p>
<p>echo &#8220;at line &#8221; . __LINE__ . &#8221; memory is &#8221; . memory_get_usage(true) . &#8220;\n&#8221;;</p>
<p>$log = array();<br />
for ($i = 0; $i  microtime(true),<br />
			&#8216;memory&#8217; =&gt; memory_get_usage(true),<br />
			&#8216;file&#8217; =&gt; __FILE__<br />
		);<br />
}</p>
<p>echo &#8220;at line &#8221; . __LINE__ . &#8221; memory is &#8221; . memory_get_usage(true) . &#8220;\n&#8221;;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Logging PHP script memory usage &#124; PHP Readings</title>
		<link>http://www.davedevelopment.co.uk/2008/05/12/log-memory-usage-using-declare-and-ticks-in-php/comment-page-1/#comment-51984</link>
		<dc:creator>Logging PHP script memory usage &#124; PHP Readings</dc:creator>
		<pubDate>Mon, 19 May 2008 09:55:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.davedevelopment.co.uk/?p=59#comment-51984</guid>
		<description>[...] Marshall posted article about php script memory usage logging. Memory logging is important because you may know haw many [...]</description>
		<content:encoded><![CDATA[<p>[...] Marshall posted article about php script memory usage logging. Memory logging is important because you may know haw many [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Konr Ness</title>
		<link>http://www.davedevelopment.co.uk/2008/05/12/log-memory-usage-using-declare-and-ticks-in-php/comment-page-1/#comment-51716</link>
		<dc:creator>Konr Ness</dc:creator>
		<pubDate>Fri, 16 May 2008 15:52:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.davedevelopment.co.uk/?p=59#comment-51716</guid>
		<description>Very timely article. Thank you. I was debugging a large online store that was using 25+MB of memory on the first load. I modified it slightly to not use sessions, and also show which file and what line of the file was being run at each tick:

$memory_usage = array();
$start_time = microtime(true);
function log_memory(){
    global $memory_usage;
    global $start_time;
    $stacktrace = debug_backtrace();
    $memory_usage[] = array(
        &#039;time&#039; =&gt; microtime(true) - $start_time,
        &#039;memory&#039; =&gt; memory_get_usage(),
        &#039;file&#039; =&gt; $stacktrace[1][&#039;file&#039;] . &#039;:&#039; . $stacktrace[1][&#039;line&#039;]
    );
}

declare(ticks = 100);
register_tick_function(&#039;log_memory&#039;);</description>
		<content:encoded><![CDATA[<p>Very timely article. Thank you. I was debugging a large online store that was using 25+MB of memory on the first load. I modified it slightly to not use sessions, and also show which file and what line of the file was being run at each tick:</p>
<p>$memory_usage = array();<br />
$start_time = microtime(true);<br />
function log_memory(){<br />
    global $memory_usage;<br />
    global $start_time;<br />
    $stacktrace = debug_backtrace();<br />
    $memory_usage[] = array(<br />
        &#8216;time&#8217; =&gt; microtime(true) &#8211; $start_time,<br />
        &#8216;memory&#8217; =&gt; memory_get_usage(),<br />
        &#8216;file&#8217; =&gt; $stacktrace[1]['file'] . &#8216;:&#8217; . $stacktrace[1]['line']<br />
    );<br />
}</p>
<p>declare(ticks = 100);<br />
register_tick_function(&#8217;log_memory&#8217;);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: EllisGL</title>
		<link>http://www.davedevelopment.co.uk/2008/05/12/log-memory-usage-using-declare-and-ticks-in-php/comment-page-1/#comment-51493</link>
		<dc:creator>EllisGL</dc:creator>
		<pubDate>Wed, 14 May 2008 19:54:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.davedevelopment.co.uk/?p=59#comment-51493</guid>
		<description>Watch out, register_tick_function will crashed on threaded servers. Also I haven&#039;t been able to get it to work in a windows environment yet.</description>
		<content:encoded><![CDATA[<p>Watch out, register_tick_function will crashed on threaded servers. Also I haven&#8217;t been able to get it to work in a windows environment yet.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Link Bundle - May 14 &#124; franzone.com</title>
		<link>http://www.davedevelopment.co.uk/2008/05/12/log-memory-usage-using-declare-and-ticks-in-php/comment-page-1/#comment-51475</link>
		<dc:creator>Link Bundle - May 14 &#124; franzone.com</dc:creator>
		<pubDate>Wed, 14 May 2008 16:49:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.davedevelopment.co.uk/?p=59#comment-51475</guid>
		<description>[...] Bundle - May 14  Author : Jonathan Franzone No Comments   Log memory usage using declare and ticks in PHP Dave Marshall, a web developer living in Hull, England, share a really quick and simple trick to [...]</description>
		<content:encoded><![CDATA[<p>[...] Bundle &#8211; May 14  Author : Jonathan Franzone No Comments   Log memory usage using declare and ticks in PHP Dave Marshall, a web developer living in Hull, England, share a really quick and simple trick to [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
