> During our site rewrite, we opted to use the request scope > over the variables scope for all "view" (CFM) pages. We use > onRequestStart() to make sure certain global site variables > are available in the request scope. > > After reading this article: > http://www.schierberl.com/cfblog/index.cfm/2006/10/16/memoryLe > ak_variablesScope > > it turns out using the request scope everywhere was a great > boon to the project. One of our legacy applications uses > Application.cfm, relies on the variables scope and has major > memory issues. If you look down in his Summary, #4 says > "Calling structClear(variables) in onRequestEnd.cfm will > destroy unwanted references tied to variables scope". > > We added this code to one server in the middle of the day and > watched the memory on that server drop like a rock as soon as > it deployed. We promoted it to the rest of the servers and > they've all been behaving much better ever since.
I read that article, and while I'm glad this turned out well for you, there seems to be a serious misunderstanding in the article about how Java garbage collection works in CF. The garbage collection doesn't run after every request, by default - and you wouldn't want it to, either. Garbage collection is an expensive operation. And just destroying the unwanted references in onRequestEnd.cfm or the onRequestEnd method in Application.cfc isn't going to change that - it just means that those variables will be immediately eligible for garbage collection whenever it runs, as long as those variables have no other references in the stack. This isn't a memory leak. Java will eventually reclaim and reallocate that memory. That said, I'm not sure what's different about using Request variables in this way, since they're just references like any other reference, and the values stored in the heap should be destroyed by the garbage collector the same way. Finally, if you're creating truly global site variables, why not just use the Application scope? That's what it's for, after all. You don't have to worry about the silly locking issues like you did with CF 5 and earlier. Of course, if things are working as they are, it's probably not worth changing now. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ Fig Leaf Software provides the highest caliber vendor-authorized instruction at our training centers in Washington DC, Atlanta, Chicago, Baltimore, Northern Virginia, or on-site at your location. Visit http://training.figleaf.com/ for more information! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;192386516;25150098;k Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:305984 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

