How cfloop query= killed a ColdFusion server

Version 5 by Marc Esher
on Feb 22, 2011 12:26.

compared with
Current by Marc Esher
on Dec 30, 2012 14:12.

This line was removed.
This word was removed. This word was added.
This line was added.

Changes (4)

View page history
A process in one of our internal tools takes a while to run. In this case, a specific instance was crashing due to Java Heap Space errors. The image on the top shows the heap \-\- with a snapshot taken while the application was in its death throes \-\- prior to fixing the problem. The image on the bottom shows the heap \-\- with a snapshot taken at roughly the same time during the application's run \-\- after making 2 small code changes. One server is dead; the other is alive. This is our story.
h1. The code, before
As the app was dying, I took a heap dump (*[described here... it's easy|]*) and saw that a thing called coldfusion.runtime.CFDummyComponent was consuming over 800MB of Ram. Drilling down a few levels, I saw thousands of "coldfusion.tagext.lang.LoopTag". Drilling into one of those, I saw that for each loop tag, there were 5000 coldfusion.sql.imq.Row objects. 5000 because that's how many records we were looping over in that cfloop.

h1. The code, after
What's more, during the running of the application, *retained heap dropped from 882 MB to 52 MB*, simply by changing the cfloop style.

h1. Conclusion