Re: Variable Scoping in CF8, CF9
On Thu, Dec 23, 2010 at 9:16 AM, Matthew Reinbold wrote: > I know that correctly scoping variables in ColdFusion is important to prevent > unexpected results if a variable is "accidentally" reused elsewhere in a CFC. > But, if I remember correctly, in CFMX there were some pretty nasty memory > leaks that could occur if variables weren't scoped correctly. Hmm, it wasn't related to memory leaks so much as thread safety - which applies to all versions of all CFML engines when you're using CFCs stored in scopes that are shared between multiple requests and it's much the same problem you have sharing data between requests anyway (it's just easier to trip over with the implicit, shared, VARIABLES scope in CFCs). -- Sean A Corfield -- (904) 302-SEAN Railo Technologies, Inc. -- http://getrailo.com/ An Architect's View -- http://corfield.org/ "If you're not annoying somebody, you're not really alive." -- Margaret Atwood ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:340258 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Variable Scoping in CF8, CF9
On Thu, Dec 23, 2010 at 10:16 AM, Matthew Reinbold wrote: > > I know that correctly scoping variables in ColdFusion is important to prevent > unexpected results if a variable is "accidentally" reused elsewhere in a CFC. > But, if I remember correctly, in CFMX there were some pretty nasty memory > leaks that could occur if variables weren't scoped correctly. > > Does that apply to newer (8,9) versions of ColdFusion? Yup. All function-local variables in a CFC should be var scoped. CF 9 did introduce the "local" scope inside of CFC methods, so doing this: is functionally equivalent to doing: So while there are now 2 ways to declare a variable as local to a given function (assuming you're on CF 9), the requirement still remains that you do need to scope these variables properly in order to avoid leakage. -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:340256 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Variable Scoping in CF8, CF9
I know that correctly scoping variables in ColdFusion is important to prevent unexpected results if a variable is "accidentally" reused elsewhere in a CFC. But, if I remember correctly, in CFMX there were some pretty nasty memory leaks that could occur if variables weren't scoped correctly. Does that apply to newer (8,9) versions of ColdFusion? - Matthew ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:340255 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm