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.
![Monkey T-Shirt [Back]](http://webmonkeyswithlaserbeams.files.wordpress.com/2008/06/monkey_tshirt_back.jpg?w=210&h=210)
![Monkey T-Shirt [Front]](http://webmonkeyswithlaserbeams.files.wordpress.com/2008/06/monkey_tshirt_front.jpg?w=210&h=210)