Categories
- General (22)
- Talking (10)
- Thinking (58)
- Apple (2)
- Browsers (4)
- Business (16)
- Databases (6)
- MySQL (3)
- SQL Server (1)
- Design (3)
- E-commerce (3)
- Marketing (2)
- Mobile (1)
- Networking (2)
- Programming (30)
- ColdFusion (24)
- Java (1)
- Javascript (6)
- PHP (6)
- Ruby (1)
- Web 2.0 (3)
- Web Servers (3)
- IIS (3)
- Windows (11)
- Walking (1)
Archives
- July 2010 (1)
- June 2010 (1)
- March 2010 (1)
- February 2010 (1)
- January 2010 (13)
- December 2009 (3)
- July 2009 (2)
- June 2009 (1)
- May 2009 (1)
- April 2009 (8)
- March 2009 (6)
- February 2009 (15)
- January 2009 (4)
- December 2008 (3)
- November 2008 (2)
- September 2008 (2)
- August 2008 (2)
- November 2007 (2)
- September 2007 (1)
- April 2007 (5)





Memory leaks with Coldfusion 8
For the past few weeks I’ve been incognito due to some memory leak issues we’ve been having with our new app. It is essentially a rewrite of our existing web application using Object Oriented techniques and embraces the Model-View-Controller paradigm. It really is a pretty little thing but unfortunately she crumbled under the weight of the world wide web. Anyone who has faced the memory leak problem will know that it is not an easy one to crack and it takes time to determine the exact issue. There are a lot of articles around that have excellent information which were all very helpful in my quest for a solution.
The system made a lot of use of the session and application scope for caching objects which was the first issue that we had to overcome. It seemed like a good idea, you’ve got loads of memory, you have a finite amount of objects that can be called for each session why not persist them. The problem is that ColdFusion 8 seems to have an issue with complex objects (i.e. CFCs) stored in the session and application scopes. The reason I say this is that we were seeing a very, very strange thing happening to the memory on our server. When load testing was run, the server was fine, the memory steadily increased until the initial sessions began expiring and then the average of memory usage plateaued, which is what you like to see. However, once the load test ended the memory steadily increased until it crashed the CF instance. Weird right? And so the search for a solution began. I came across a few helpful articles:
http://www.ghidinelli.com/2009/07/16/finding-memory-leaks-coldfusion-jvm
http://www.schierberl.com/cfblog/index.cfm/2006/10/12/ColdFusion_memoryLeak_profiler
http://www.alagad.com/blog/post.cfm/troubleshooting-coldfusion-performance-analysis-part-ii
These were tremendously helpful in assisting me in finding the solution. The last post from Alagad was the one that helped cure my issue in the end. You need to ensure that when making copies of persistent scoped variables that they are deep copied or used in a local scope within CFC functions. However, bear in mind that there are many causes for memory leaks and you should spend the time in figuring out the exact cause of your problem. I found the MAT tool supremely useful.
Here are some tips for curing memory issues:
Hopefully these will help someone else going forward.
UPDATE 16/05/2010: Point #6 should be, ensure you scope your variables correctly. The THIS scope has its own set of limitations. Ensure that all variables (including loop indices) have the proper scope to avoid leakage.
Related Posts