In working on Financial Peace University Online last year, I became aware of a really ugly memory leak that had developed in the app (thankfully it was still in development, not in production). It took a few days to track down, but when I found it, it proved to have some implications that applied to all our ColdFusion web apps.
First I’ll describe the environment:
- ColdFusion 7 running in JRun 4
- Mach-II 1.1 framework
- ColdSpring object factories
I discovered that for each singleton instance of a cfc that the ColdSpring factories provided, a little memory was leaked and never garbage collected. I simplified things to remove Mach-II, ColdSpring, and eventually everything except the simplest form I could think of. A cfm would create an instance of a cfc that had a method in it that would return a reference to itself. Then the cfm would go through 100 iterations of calling that method and place the result in an array. So I would have an array with 100 references to the same object, and still, the memory leak was present.
Finally I noticed that on my cfc method, I hadn’t specified output=”false”, though I had specified it on the cfcomponent tag. Adding output=”false” to the method that returned a reference to the cfc cured the memory leak. It seems bizarre, but if a memory leak was obvious, it wouldn’t have made it into the release version of ColdFusion.
Tags: ColdFusion
July 1, 2008 at 9:55 am
Thanks,
It is very attractive site.
it improve my performence.
this site is nice and very helpful.
Interesting series and many good points.
very nice blog…..
June 30, 2009 at 5:48 pm
Thanks for the good information.
I’m curious though. What if you have a method that does produce output? Will setting output=”true” leak memory or does the leak only exist if the parameter is not set?
Also, how have you been testing for memory leaks. I have been dealing with similar issues but have been having a hard time tracking down the culprit. It seems there are a lot of people struggling with memory leaks in CF 7 and it seems that everyone is coming to different conclusions.
July 1, 2009 at 7:45 pm
Jim, thanks for the comment. I can’t say if it’s just the act of setting the output parameter that eliminates the memory leak as I only tested by setting it to false.
As for how I tested, I used the method detailed in this post by my co-worker: https://webmonkeyswithlaserbeams.wordpress.com/2009/01/21/how-much-memory-does-this-take/.
November 21, 2009 at 12:26 pm
Just wanted to say you guy rock! (Glad to have met you guys from Dave Ramsey at BFusion/BFlex). Just wanted to let you know that this post helped me diagnose a memory leak in Mach-II (when reloading from the dashboard). It appears that this issue affect CF8 even with cumulative hot fix 3 which supposedly fixed a memory leak issue CFCs and memory scopes.
Also beware that I had to fix a bunch of missing output attributes in our ColdSpring copy as well. I’ll post a blog post about this later.
July 26, 2010 at 7:26 am
This issue was fixed in Cumulative Hot fix 4 for ColdFusion 8.0.1. You can download it from here:
http://kb2.adobe.com/cps/402/kb402604.html#CF801