TechnicallyChris.com

Technical and Personal Ramblings of a Bostonian
  • Home
  • About Chris
  • Donate
  • Contact Chris
Home > ColdFusion > Storing Too Much in ColdFusion Variables – My Lesson Learned

Storing Too Much in ColdFusion Variables – My Lesson Learned

October 25th, 2006
Goto comments Leave a comment

As part of a recent a ColdFusion project, I needed to query an Oracle database and accept anywhere from 0 to 30k-40k records, then export into a CSV. It didn’t seem like too difficult of a problem at first. I used Toad to build the perfect query. Once optimized to pull down the max amount of records in the least amount of time, I copied to ColdFusion, built my front end, tested, and released. How’d I do it? Seemed simple — I setup a variable with a CSV header row, and then appended the variable record by record with the new data, and at the end CFFILE’d it all into a temp file which I then presented to the user.

Almost immediately after releasing the page into the application, I started having memory issues on my ColdFusion box. I’d watch the task list and just see JRUN rise to unreasonable percentages, and every so often – just hang. Killing the process and restarting the service was the only solution. It was obvious that the report was the problem, and it needed to be fixed ASAP.

The solution is something that should have come to mind immediately. Trying to store upwards of 30k records in a variable probably was not the smartest solution I’ve come up with, and probably was maxing out those few gigs of RAM that I have allocated to that box. My solution? Instead of writing the data out to a temp file when I had collected it all to begin with, I change the code so that it would export after I had a complete record, and then clearing the variable. Not only did this alleviate all of the JRUN issues I was having, but also sped up the report significantly.

My lesson learned? Just because you can do something, doesn’t mean it’s the best way; take time to think. Unfortunately deadlines will often conflict with your ability to reason with your code ;)

If you enjoyed this article or it helped you in any way, I’d appreciate it if you’d post a comment below to let me know. All code examples are for demonstration only and should be used at your own risk. I cannot accept liability for unexpected results.

Chris ColdFusion ColdFusion

Comments (0) Trackbacks (0) Leave a comment Trackback
  1. No comments yet.
  1. No trackbacks yet.
Subscribe to comments feed
Accessing Remote File Shares with ColdFusion Getting Firefox to Support Integrated Windows Authentication
RSS feed
  • Google
  • Youdao
  • Xian Guo
  • Zhua Xia
  • My Yahoo!
  • newsgator
  • Bloglines
  • iNezha

Sponsored By

Read my review of Mozy here.

Recent Posts

  • Just Bought the Google Nexus One
  • Seven Things I’ve Liked About Windows 7 in Seven Day
  • What’s Happened to Customer Service (Part 2)?
  • What’s Happened to Customer Service (Part 1)?
  • Capturing S.M.A.R.T. Hard Disk Data from WMI with AutoIt
  • Adjusting DCOM Settings via Script
  • How to Manually Call the Google Cache
  • RoboForm & RoboForm2Go Product Review
  • Updated PingCell Function for Excel
  • Creating Hyperlinks in Word and Excel Longer than 256 Characters

Categories

  • ColdFusion
  • Firefox
  • Google Nexus One
  • IIS
  • McAfee EE / SafeBoot
  • Microsoft Windows
  • Oracle
  • Random Code
  • Random Technology
  • Sports and Recreation
  • Subversion
  • The Untechnological

Archives

  • January 2010
  • October 2009
  • September 2009
  • August 2009
  • July 2009
  • June 2009
  • May 2009
  • April 2009
  • March 2009
  • October 2007
  • September 2007
  • August 2007
  • January 2007
  • November 2006
  • October 2006
  • September 2006
  • August 2006
  • July 2006
  • June 2006
  • May 2006

Meta

  • Register
  • Log in
PageRank
Top WordPress
Copyright © 2006-2010 TechnicallyChris.com
Theme by mg12. Valid XHTML 1.1 and CSS 3.