<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Richard Lord &#187; Object pool</title>
	<atom:link href="http://www.richardlord.net/blog/tag/object-pool/feed" rel="self" type="application/rss+xml" />
	<link>http://www.richardlord.net</link>
	<description>Actionscript/Flex, PHP and Java developer</description>
	<lastBuildDate>Fri, 25 Jun 2010 07:34:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Object Pool class</title>
		<link>http://www.richardlord.net/blog/object-pool-class</link>
		<comments>http://www.richardlord.net/blog/object-pool-class#comments</comments>
		<pubDate>Wed, 08 Oct 2008 13:50:51 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Free code]]></category>
		<category><![CDATA[Object pool]]></category>

		<guid isPermaLink="false">http://www.bigroom.co.uk/blog/object-pool-class/</guid>
		<description><![CDATA[<p>Two of the slow operations in the flash player are object creation and garbage collection. If we pool objects - save objects when they're no longer needed and reuse them later when another object of the same type is required - then object creation is kept to a minimum and garbage collection is reduced to zero...</p>]]></description>
			<content:encoded><![CDATA[<p>Two of the slow operations in the flash player are object creation and garbage collection. If we pool objects &#8211; save objects when they&#8217;re no longer needed and reuse them later when another object of the same type is required &#8211; then object creation is kept to a minimum and garbage collection is reduced to zero.</p>

<p><a href="http://blog.joa-ebert.com/">Joa Ebert</a> discussed this in his presentation at <a href="http://www.flashonthebeach.com/">Flash on the Beach</a>. I already use specific object pooling in the <a href="http://flintparticles.org/">Flint particles library</a>, but while he was talking I had an idea and wrote a class for generic object pooling of all object types. I finally had time to test the class, and it works as expected, so I&#8217;ve added it to my <a href="http://code.google.com/p/bigroom/">open code repository</a>, where you can <a href="http://bigroom.googlecode.com/files/ObjectPool.zip">download it</a>.</p>

<p>The object pool class manages pooling of all objects through two simple methods. You can obtain an object from it like this</p>

<pre class="code">var obj:SomeClass = ObjectPool.getObject( SomeClass );</pre>

<p>If there are any such objects in the pool, one of them will be returned. If there are no such objects in the pool, a new one will be created and returned to you.</p>

<p>When you no longer need an object, you can add it to the pool for later reuse like this</p>

<pre class="code">ObjectPool.disposeObject( obj );</pre>

<p>The object doesn&#8217;t have to have been created through the pool &#8211; any object can be dropped into the pool with the disposeObject method.</p>

<p>The source code is available in <a href="http://code.google.com/p/bigroom/wiki/ObjectPool">my google code repository</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.richardlord.net/blog/object-pool-class/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
