<?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: PHP garbage collection and memory leaks</title>
	<atom:link href="http://blog.perplexedlabs.com/2008/02/25/php-garbage-collection-and-memory-leaks/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.perplexedlabs.com/2008/02/25/php-garbage-collection-and-memory-leaks/</link>
	<description>web development war stories from the frontlines to the backend</description>
	<lastBuildDate>Sat, 29 Oct 2011 10:05:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
	<item>
		<title>By: Gary Reckard</title>
		<link>http://blog.perplexedlabs.com/2008/02/25/php-garbage-collection-and-memory-leaks/comment-page-1/#comment-3267</link>
		<dc:creator>Gary Reckard</dc:creator>
		<pubDate>Sun, 05 Sep 2010 21:03:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.perplexedlabs.com/2008/02/25/php-garbage-collection-and-memory-leaks/#comment-3267</guid>
		<description>Wow, thank you! This actually solved my problem. I&#039;m importing 30k+ products into an ecommerce system, and was only getting like 100 or so done at a time. I has also tried a method of picking up where the script died, but that wouldn&#039;t be feasible. You rock.</description>
		<content:encoded><![CDATA[<p>Wow, thank you! This actually solved my problem. I&#39;m importing 30k+ products into an ecommerce system, and was only getting like 100 or so done at a time. I has also tried a method of picking up where the script died, but that wouldn&#39;t be feasible. You rock.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul</title>
		<link>http://blog.perplexedlabs.com/2008/02/25/php-garbage-collection-and-memory-leaks/comment-page-1/#comment-2725</link>
		<dc:creator>Paul</dc:creator>
		<pubDate>Mon, 19 Oct 2009 14:31:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.perplexedlabs.com/2008/02/25/php-garbage-collection-and-memory-leaks/#comment-2725</guid>
		<description>This helped... I&#039;m working with objects, so it&#039;s a little different for me.  &lt;br&gt;&lt;br&gt;You need to cache objects that are created within a method, where the method&#039;s return value is the result of a function call on the newly created object.&lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;br&gt;class a {&lt;br&gt;  function b() { &lt;br&gt;    $c = new c();&lt;br&gt;    // memory leaking here.&lt;br&gt;    return $c-&gt;d();&lt;br&gt;  }&lt;br&gt;}&lt;br&gt;class c { &lt;br&gt;  function d() { &lt;br&gt;    return 3+5;&lt;br&gt;  }&lt;br&gt;}&lt;br&gt;&lt;br&gt;Fixed:&lt;br&gt;class a {&lt;br&gt;  var $objc;&lt;br&gt;  function b() { &lt;br&gt;    // create if not exists, else use cached object.&lt;br&gt;    if( !is_object($this-&gt;objc) ) { &lt;br&gt;      $this-&gt;objc = new c();&lt;br&gt;    }&lt;br&gt;    return $this-&gt;objc-&gt;d();&lt;br&gt;  }&lt;br&gt;}&lt;br&gt;&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>This helped&#8230; I&#39;m working with objects, so it&#39;s a little different for me.  </p>
<p>You need to cache objects that are created within a method, where the method&#39;s return value is the result of a function call on the newly created object.</p>
<p>&lt;pre&gt;<br />class a {<br />  function b() { <br />    $c = new c();<br />    // memory leaking here.<br />    return $c-&gt;d();<br />  }<br />}<br />class c { <br />  function d() { <br />    return 3+5;<br />  }<br />}</p>
<p>Fixed:<br />class a {<br />  var $objc;<br />  function b() { <br />    // create if not exists, else use cached object.<br />    if( !is_object($this-&gt;objc) ) { <br />      $this-&gt;objc = new c();<br />    }<br />    return $this-&gt;objc-&gt;d();<br />  }<br />}<br />&lt;/pre&gt;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul</title>
		<link>http://blog.perplexedlabs.com/2008/02/25/php-garbage-collection-and-memory-leaks/comment-page-1/#comment-2701</link>
		<dc:creator>Paul</dc:creator>
		<pubDate>Mon, 19 Oct 2009 10:31:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.perplexedlabs.com/2008/02/25/php-garbage-collection-and-memory-leaks/#comment-2701</guid>
		<description>This helped... I&#039;m working with objects, so it&#039;s a little different for me.  &lt;br&gt;&lt;br&gt;You need to cache objects that are created within a method, where the method&#039;s return value is the result of a function call on the newly created object.&lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;br&gt;class a {&lt;br&gt;  function b() { &lt;br&gt;    $c = new c();&lt;br&gt;    // memory leaking here.&lt;br&gt;    return $c-&gt;d();&lt;br&gt;  }&lt;br&gt;}&lt;br&gt;class c { &lt;br&gt;  function d() { &lt;br&gt;    return 3+5;&lt;br&gt;  }&lt;br&gt;}&lt;br&gt;&lt;br&gt;Fixed:&lt;br&gt;class a {&lt;br&gt;  var $objc;&lt;br&gt;  function b() { &lt;br&gt;    // create if not exists, else use cached object.&lt;br&gt;    if( !is_object($this-&gt;objc) ) { &lt;br&gt;      $this-&gt;objc = new c();&lt;br&gt;    }&lt;br&gt;    return $this-&gt;objc-&gt;d();&lt;br&gt;  }&lt;br&gt;}&lt;br&gt;&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>This helped&#8230; I&#39;m working with objects, so it&#39;s a little different for me.  </p>
<p>You need to cache objects that are created within a method, where the method&#39;s return value is the result of a function call on the newly created object.</p>
<p>&lt;pre&gt;<br />class a {<br />  function b() { <br />    $c = new c();<br />    // memory leaking here.<br />    return $c-&gt;d();<br />  }<br />}<br />class c { <br />  function d() { <br />    return 3+5;<br />  }<br />}</p>
<p>Fixed:<br />class a {<br />  var $objc;<br />  function b() { <br />    // create if not exists, else use cached object.<br />    if( !is_object($this-&gt;objc) ) { <br />      $this-&gt;objc = new c();<br />    }<br />    return $this-&gt;objc-&gt;d();<br />  }<br />}<br />&lt;/pre&gt;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brandon Savage</title>
		<link>http://blog.perplexedlabs.com/2008/02/25/php-garbage-collection-and-memory-leaks/comment-page-1/#comment-2689</link>
		<dc:creator>Brandon Savage</dc:creator>
		<pubDate>Wed, 09 Sep 2009 14:33:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.perplexedlabs.com/2008/02/25/php-garbage-collection-and-memory-leaks/#comment-2689</guid>
		<description>This did help me. Thanks for posting it. I did exactly what you did and my application works properly.</description>
		<content:encoded><![CDATA[<p>This did help me. Thanks for posting it. I did exactly what you did and my application works properly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom Lancaster</title>
		<link>http://blog.perplexedlabs.com/2008/02/25/php-garbage-collection-and-memory-leaks/comment-page-1/#comment-1068</link>
		<dc:creator>Tom Lancaster</dc:creator>
		<pubDate>Sun, 15 Mar 2009 07:00:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.perplexedlabs.com/2008/02/25/php-garbage-collection-and-memory-leaks/#comment-1068</guid>
		<description>thanks for this insight. You&#039;ve just saved me a lot of time on a script that I&#039;m using to update my whole database. This technique works.</description>
		<content:encoded><![CDATA[<p>thanks for this insight. You&#8217;ve just saved me a lot of time on a script that I&#8217;m using to update my whole database. This technique works.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

