Currently, you're creating an instance on every page that needs it, right? So 
let's say you have 1 CFC that's used across 20 pages. It doesn't matter how 
many functions are in the CFC and whether or not you use them all. The overhead 
comes from creating an instance of the object at least 20 times.

Now let's say that you have 100 users and they each call those 20 pages at 
least once. Now you've created an instance of that CFC 2,000 times. This will 
increase as you get more users.

Instead, create one instance of the CFC and place it in the application scope 
when the application starts. You can do this with onApplicationStart() in 
Application.cfc.

You can then reference the CFC from memory like this:

<cfinvoke component="#application.reviews#"           
       method="getTopTenTitle"
       campus = "#URL.Campus#"
       returnvariable="qGetTopTenTitle"> 

You can see a bit more here under "Reducing calls to createObject()":
http://www.iknowkungfoo.com/blog/index.cfm/2007/9/11/Object-Oriented-Coldfusion--5--The-Gateway-Object

HTH, 

Adrian

> Hello All, 
> 
> I've gotten into the habit of beginning a page by creating an object: 
> 
> 
> <cfobject component="#application.cfcpath#reviews" name="reviews"> 
> 
> Below that, I use any number of cfinvokes thusly: 
    
> <cfinvoke component="#reviews#"           
              
> method="getTopTenTitle"
              
> campus = "#URL.Campus#"
              
> returnvariable="qGetTopTenTitle"> 
> 
> In the component I'll have functions that are not called by the page.  
> They are used by other pages. When I turn a component into an object 
> am I needlessly calling all the functions inside that component and is 
> this not a good idea? 
> 
> Thanks in advance, 
> 
> John 


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:304205
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to