Randy,

If your CFC is a collection of methods then this is fine.. But if you intend
on persisting the return value (say in the session scope) then you may end
up with some memory issues.

We found that storing a return query from an application cached CFC in the
session scope caused memory to be allocated on the heap that could not be
recoverred by Garbage collection. By default the pass by reference caused
the object returned from the application scoped method to live in the
application scope and be referenced by the session scope.

I wrote about it here.

http://www.coldfusionmuse.com/index.cfm/2008/2/12/leaky.heap.jvm

So.. If you understand the implications then yes... Storing in the
application scope is an option.

I have found however, that there is not a lot of overhead to the
createObject( ) call once the CFC is compiled (run for the first time) so
caching is often unnecessary.

-Mark
 


Mark A. Kruger, CFG, MCSE
(402) 408-3733 ext 105
www.cfwebtools.com
www.coldfusionmuse.com
www.necfug.com

-----Original Message-----
From: Randy [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, September 24, 2008 8:07 AM
To: CF-Talk
Subject: CFC Objects (Best Practice)?

To those who use CFCs as Objects:

Is it best to create the CFC objects within the application or session scope
to be called throughout the application?

Ex:

-- OnApplicationStart
<cfscript>
application.lookupCFC = createobject('component','cfcs.lookup');
 </cfscript>

-- OnSessionStart
 <cfscript>
session.lookupCFC = createobject('component','cfcs.lookup');
 </cfscript>




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

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

Reply via email to