Author: Steven Neiland

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" />

The Results

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

First: 1
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
Last: 2

The Conclusion

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.

1 2

What Do You Think?

Reader Comments

Post a Comment

Comment Etiquette:

  • Please keep comments on-topic.
  • Please do not post unrelated questions or large chunks of code.
  • Please do not engage in flaming/abusive behaviour.
  • Comments that contain or appear to be advertisments, will not be published.
  • Comments that appear to be created for the purpose of linkbuilding to commercial sites will be removed.

We are all adults here so play nice.


Archives Blog Listing

Tag Listing

Learn CF In A Week


Fork me on GitHub