The need to understand how ColdFusion handles variable scopes is essential to keeping both your application and server running smoothly and preventing performance decreases.Â Scoping your variables takes seconds at the time of development.Â I frequently talk with customers who have ‘memory leaks’ and are quick to blame the application server, however a ColdFusion application server that doesn’t run code would not typically experience a leak.
Order of Evaluation
Should you specify a variable name with out a scope, ColdFusion has to search through the different scopes in order to determine if it exists.Â As you might imagine, if this is on a very frequently requested page, this could cause significant slow-downs and performance issues.
- Function local (only UDFs and CFCs)
- Thread local (only inside threads)
If the variable exists in any of the other scopes, it must be scoped properly to be accessed.