I notice that every variable created in a CFC's initialization section stays in memory for the life of the object. Is there a way to avoid that? One way I thought of is to create every temporary variable in a particular structure, then reset that structure at the end of the initialization, but I'm wondering if there is a better way. Here's a demonstration of my method, the class is employees, which creates a collection of employee objects, using 'foo' as the throw away structure. I'd appreciate your comments or suggestions.
<!--- this component will create structure 'priv' when initialized. The foo structure is discarded. ---> <cfcomponent name="employees"> <cfquery name="foo.rs"> select name, department from emp </cfquery> <cfloop query="foo.rs"> <!--- once this loop is done, foo.rs is no longer necc. ---> <cfset priv[name] = createObject("component", 'employee')> <cfset priv[name].new(name, department)> </cfloop> <cfset foo = ''> <!--- free the foo memory ---> <cffunction name="getEmployeeByName" return="employee"> <cfargument name="name"> <cfreturn priv[arguments.name]> </cffunction> </cfcomponent> *** The information in this e-mail is confidential and intended solely for the individual or entity to whom it is addressed. If you have received this e-mail in error please notify the sender by return e-mail, delete this e-mail, and refrain from any disclosure or action based on the information. **** ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Get the mailserver that powers this list at http://www.coolfusion.com Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4