<?xml version="1.0" encoding="utf-8"?><!-- generator="wordpress/1.5.1.3" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Object pooling, part 8 - monitoring the pool&#8217;s performance</title>
	<link>http://www.sturmnet.org/blog/archives/2005/10/18/object-pooling8/</link>
	<description>General musings and programming stuff</description>
	<pubDate>Tue, 06 Jan 2009 13:54:49 +0000</pubDate>
	<generator>http://wordpress.org/?v=1.5.1.3</generator>

	<item>
		<title>by: NL</title>
		<link>http://www.sturmnet.org/blog/archives/2005/10/18/object-pooling8/#comment-235849</link>
		<pubDate>Wed, 12 Nov 2008 13:43:20 +0000</pubDate>
		<guid>http://www.sturmnet.org/blog/archives/2005/10/18/object-pooling8/#comment-235849</guid>
					<description>Hey Oliver,

First let me thank you for a through document that is really helpful. I need to implement object pooling and will definitely do some serious copy/paste :)

I do have a question.My poolable object is using some &amp;#34;unmanaged&amp;#34; resources such as open files, connections and other external resources. In a normal case I just call MyObject.Dispose() method to make sure all these resources are cleared. I an thinking that if i would use your object pooling this method will never get called. I was thinking of added another method to IObjectFactory, that looks like that:

public interface IObjectFactory&amp;#60;T&amp;#62; {
		T CreateObject( );
		void DisposeObject(T objectToDispose);
}

My object factory's DisposeObject will call the object's Dispose method.

Then in ShrinkPoolBy i'll call objectFactory.DisposeObject(unusedSlot.PoolObject) just before removing it from the list.

My problem is that if the unusedSlot is empty it will create the object. which is silly.

I was wondering you might suggest what is the bast way to handle such issue.

Thanks</description>
		<content:encoded><![CDATA[	<p>Hey Oliver,</p>
	<p>First let me thank you for a through document that is really helpful. I need to implement object pooling and will definitely do some serious copy/paste <img src='http://www.sturmnet.org/blog/wp-images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
	<p>I do have a question.My poolable object is using some &quot;unmanaged&quot; resources such as open files, connections and other external resources. In a normal case I just call MyObject.Dispose() method to make sure all these resources are cleared. I an thinking that if i would use your object pooling this method will never get called. I was thinking of added another method to IObjectFactory, that looks like that:</p>
	<p>public interface IObjectFactory&lt;T&gt; {<br />
		T CreateObject( );<br />
		void DisposeObject(T objectToDispose);<br />
}</p>
	<p>My object factory&#8217;s DisposeObject will call the object&#8217;s Dispose method.</p>
	<p>Then in ShrinkPoolBy i&#8217;ll call objectFactory.DisposeObject(unusedSlot.PoolObject) just before removing it from the list.</p>
	<p>My problem is that if the unusedSlot is empty it will create the object. which is silly.</p>
	<p>I was wondering you might suggest what is the bast way to handle such issue.</p>
	<p>Thanks
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Oliver Sturm</title>
		<link>http://www.sturmnet.org/blog/archives/2005/10/18/object-pooling8/#comment-90305</link>
		<pubDate>Tue, 24 Apr 2007 08:49:06 +0000</pubDate>
		<guid>http://www.sturmnet.org/blog/archives/2005/10/18/object-pooling8/#comment-90305</guid>
					<description>Hi Bruce - what do you mean &amp;#34;most of the applications are web applications&amp;#34;? What applications? In any case, my code is of course &amp;#34;just&amp;#34; a sample of how to implement object pooling, not an out of the box product for all scenarios.

As to the ASP.NET environment, I don't exactly understand what you mean with your question. An object pool can be used in all situations where you want to have a number of objects available for shared (?) use. To use it, you'll always have to set it up at some point, then make it available to callers. Maybe if you could give an example of the kind of objects that you're trying to make available from your ASP.NET application, that might help me understand where you see the problem in that case.

Finally, I don't know if anybody ever went and used my source code in their applications. I'm sure that object pooling as a technical approach is used in real world applications all the time. It's a common technique that is used by many server systems. ADO.NET supports it, as one example, to allow you to get a database connection from a pool instead of creating it all the time. Web servers normally work that way, having a bunch of response threads running in a pool to avoid having to start one up when a request comes in.

The idea with object pooling is always that it is somehow a better idea to have an object readily available for a certain task, instead of having to create it and set it up when the task comes along. Now, creating an object is not really something that takes any significant time - it's the setting up step that can take more time than we would like (opening network connections, database connections, reading metadata, whatever). In the end your application is supposed to work more performantly with object pooling in place. If it doesn't, it's not the fault of the object pooling approach, but rather of you using that approach in a situation where it's not appropriate or useful.</description>
		<content:encoded><![CDATA[	<p>Hi Bruce - what do you mean &quot;most of the applications are web applications&quot;? What applications? In any case, my code is of course &quot;just&quot; a sample of how to implement object pooling, not an out of the box product for all scenarios.</p>
	<p>As to the ASP.NET environment, I don&#8217;t exactly understand what you mean with your question. An object pool can be used in all situations where you want to have a number of objects available for shared (?) use. To use it, you&#8217;ll always have to set it up at some point, then make it available to callers. Maybe if you could give an example of the kind of objects that you&#8217;re trying to make available from your ASP.NET application, that might help me understand where you see the problem in that case.</p>
	<p>Finally, I don&#8217;t know if anybody ever went and used my source code in their applications. I&#8217;m sure that object pooling as a technical approach is used in real world applications all the time. It&#8217;s a common technique that is used by many server systems. ADO.NET supports it, as one example, to allow you to get a database connection from a pool instead of creating it all the time. Web servers normally work that way, having a bunch of response threads running in a pool to avoid having to start one up when a request comes in.</p>
	<p>The idea with object pooling is always that it is somehow a better idea to have an object readily available for a certain task, instead of having to create it and set it up when the task comes along. Now, creating an object is not really something that takes any significant time - it&#8217;s the setting up step that can take more time than we would like (opening network connections, database connections, reading metadata, whatever). In the end your application is supposed to work more performantly with object pooling in place. If it doesn&#8217;t, it&#8217;s not the fault of the object pooling approach, but rather of you using that approach in a situation where it&#8217;s not appropriate or useful.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Bruce</title>
		<link>http://www.sturmnet.org/blog/archives/2005/10/18/object-pooling8/#comment-90222</link>
		<pubDate>Mon, 23 Apr 2007 22:04:06 +0000</pubDate>
		<guid>http://www.sturmnet.org/blog/archives/2005/10/18/object-pooling8/#comment-90222</guid>
					<description>Did anybody actually use Object Pooling in their applications? What is the application performance impact after using Object Pooling?

Thanks.</description>
		<content:encoded><![CDATA[	<p>Did anybody actually use Object Pooling in their applications? What is the application performance impact after using Object Pooling?</p>
	<p>Thanks.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Bruce</title>
		<link>http://www.sturmnet.org/blog/archives/2005/10/18/object-pooling8/#comment-89299</link>
		<pubDate>Fri, 20 Apr 2007 22:08:30 +0000</pubDate>
		<guid>http://www.sturmnet.org/blog/archives/2005/10/18/object-pooling8/#comment-89299</guid>
					<description>Can you provide a sample or partial sample code about how to use this code in ASP.NET environment. 
Right now, most of the applications are web applications.

Thanks a lot.</description>
		<content:encoded><![CDATA[	<p>Can you provide a sample or partial sample code about how to use this code in ASP.NET environment.<br />
Right now, most of the applications are web applications.</p>
	<p>Thanks a lot.
</p>
]]></content:encoded>
				</item>
</channel>
</rss>
