Warning: This blog entry was written two or more years ago. Therefore, it may contain broken links, out-dated or misleading content, or information that is just plain wrong. Please read on with caution.
Running The Test
For the sake of being thorough I ran the test twice, first by calling the component transiently and the second time by creating an object instance and calling the runTest method.
Here is my test index.cfm file.
<h1>CFC Instationion Test</h1>
<!--- Call the runTest() method of the Component --->
<cfinvoke component="cfcinvoker" method="runtest" />
As you can see from the results below, when we specify the component attribute a new transient instance of that component is created in memory. This instance has its own memory and has no knowledge of the values in the calling components memory space.
When you think about it this makes perfect sense. If ColdFusion see's a component attribute in the cfinvoke tag then it will automatically load a new instance of the component as the process of checking if the component is the same as the caller could incur additional unneeded overhead.
CFC Instationion Test
Component specified, no increment. Expected value = 1: Actual = 1
Component specified, variable incremented. Expected value = 2: Actual = 1
Component not specified, variable incremented. Expected value = 2: Actual = 2
In the app I am working on this behavior has no functional bearing as all components were called transiently and no values are stored in the components memory space. However had a more object orientated coding pattern been used this could have led to some very strange behavior.
From a performance point of view this behavior means that extra class loading was being incurred and so removing the component attribute is an obvious choice to improve performance.