Question

In my UDFs and components I've been using the function local scope rather than the var keyword. I have Local Scope Mode set to to "always" server-wide so I don't explicitly use the local keyword (unless I'm inside a cfquery loop with conflicting field names). Are there any side-effects I should be aware of or can I always treat var and local as equivalent?

I'm not concerned whether this is good programming practise or backwards-compatible or good style or other "non-tangible" reason. I'm asking specifically about whether it affects performance or memory use or thread-safety or other effects on the application.

I cache many functions and components in shared scopes like application and session so I'm particularly curious about whether that could expose differences that wouldn't normally be seen. I remember that CFMX6.1 used to leak memory like crazy when I did this but I haven't noticed any similiar effects under Railo.

This question relates to Railo 3.3 and 4.0+ as I have different versions running.

Was it helpful?

Solution

It is very unlikely they are implemented the same. However, as long as you have made sure that your local variables have not leaked out of your function either by using var or local scope then you'll be fine. Any difference in performance will be so negligible as to be not worth concerning yourself with. I'd also like to add that Railo in my experience is a very well put together product so I would be very surprised if there was a memory problem with either of these approaches.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top